Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.3k views
in .NET FTP by (160 points)
Hey,

I'm currently trialling the edtFTPnet/PRO library, just trying to make sure it can connect to all the types of servers we require before we purchase and I've hit a bit of a snag... I can't get the certificate-based authentication to an SFTP server to work correctly, specifically it won't load the certificate from my certificate file.

The call that's failing is:
                    ftpConn.ClientCertificate = EnterpriseDT.Net.Ftp.Ssl.SSLFTPCertificate.CreateFromFile(@"C:\Apps\FtpTest\test.key");

With a SSLFTPException "Unrecognized file-type: C:\Apps\FtpTest\test.key".

The key file is an OpenSSH key, I also have a PPK (PuTTY) file of it and I've used this test.key previously with SharpSSH successfully. I've tried using Pageant to export an OpenSSL key from the ppk, which not suprisingly is identical to the original and still didn't work.

If it helps at all in knowing what kind of file it is the file I believe is an OpenSSH file starts with "-----BEGIN RSA PRIVATE KEY-----" and ends with "-----END RSA PRIVATE KEY-----".

Am I using an unsupported key format, do I need to put the key through some other app before I can use it with edtFTPnet/PRO? If so, could you recommend what applications might work?

2 Answers

0 votes
by (162k points)
Hi Tim

This is because your file doesn't contain an SSL certificate - that property is for FTPS connections (not for SFTP).

To validate an SFTP server, you need to use the KnownHosts property, and add the server's key to the KnownHostManager:

ftpConn.KnownHosts.AddKnownHost("myhostname", @"C:\Apps\FtpTest\test.key");

More details here:

http://www.enterprisedt.com/products/ed ... ation.html

It also might be that you are trying to set the client's key so that the client can authenticate via public key authentication.

If this is the case, you are in fact after:

ftpConn.ClientPrivateKeyFile = @"C:\Apps\FtpTest\test.key";
ftpConn.ClientPrivateKeyPassphrase = "mypassphrase";

More on that here:

http://www.enterprisedt.com/products/ed ... ation.html

Hope this helps.
0 votes
by (160 points)
Thanks for the quick reply Bruce.

You were right, I was in fact trying to use ClientPrivateKeyFile and not ClientCertificate, and as soon as I swapped that over it connected perfectly.

Categories

...