Discuss (FTP) and (SFTP, FTPS and SCP), our Java file transfer clients.
no avatar
User

Helen Lin

Posts

3

Joined

Fri Jun 10, 2011 3:48 am

SSLFTP: server certificate could not be validated

by Helen Lin » Fri Jun 10, 2011 4:04 am

I am trying to use implicit FTPS with server validation. Sometimes it is working and sometimes I am getting the error "Server certificate could not be validated". Can someone please help? Thanks

Here is my java code.

// at one point, I got error "certificate chain is too long, so I added the line below
SSLFTPStandardValidator.MAX_CERTIFICATE_CHAIN_LENGTH = 5;

// create client
ftp = new SSLFTPClient();

// disable standard SSL closure
ftp.setConfigFlags(SSLFTPClient.ConfigFlags.DISABLE_SSL_CLOSURE);

// set remote host
ftp.setRemoteHost(host);

// load root certificates
ftp.getRootCertificateStore().importPEMFile(serverCertFilename);

ftp.setCustomValidator(new SSLFTPStandardValidator(false));

// set implicit mode
ftp.setImplicitFTPS(true);

Here is the error mesage:
ERROR [SSLSocket] 9 Jun 2011 13:43:16.082 : internalSocket() failed - closing socket : Server certificate coul
d not be validated.
com.enterprisedt.net.puretls.cert.CertificateVerifyException: Server certificate could not be validated.
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

Re: SSLFTP: server certificate could not be validated

by support2 » Fri Jun 10, 2011 8:22 am

Is this always with the same server? Could you enable logging at the ALL level and send us the log file?
no avatar
User

Helen Lin

Posts

3

Joined

Fri Jun 10, 2011 3:48 am

by Helen Lin » Sat Jun 11, 2011 1:18 am

It is always the same server. The problem occurs randomly. Here is more log info. Thank you very much for your quick response.

INFO [ftpstest.UseFTPSWithServerValidation] 10 Jun 2011 11:13:27.537 : Creating FTPS c
lient
INFO [SSLFTPClient] 10 Jun 2011 11:13:27.568 : edtFTPj - PRO version
INFO [LicensePropertiesBase] 10 Jun 2011 11:13:27.584 : Licence expiry date: 31 Dec 9999
INFO [LicensePropertiesBase] 10 Jun 2011 11:13:27.584 : Production licence
INFO [puretls] 10 Jun 2011 11:13:27.662 : PureTLS debug level=0
INFO [com.tdsecurities.loaniq.ftpstest.UseFTPSWithServerValidation] 10 Jun 2011 11:13:27.662 : Setting configu
ration flags
INFO [com.tdsecurities.loaniq.ftpstest.UseFTPSWithServerValidation] 10 Jun 2011 11:13:27.662 : Setting remote
host
INFO [com.tdsecurities.loaniq.ftpstest.UseFTPSWithServerValidation] 10 Jun 2011 11:13:27.678 : Loading server
certificate from cert_test.pem
INFO [cryptix] 10 Jun 2011 11:13:27.693 : GLOBAL_TRACE=false
INFO [cryptix] 10 Jun 2011 11:13:27.693 : GLOBAL_DEBUG=false
INFO [cryptix] 10 Jun 2011 11:13:27.693 : GLOBAL_DEBUG_SLOW=false
INFO [com.tdsecurities.loaniq.ftpstest.UseFTPSWithServerValidation] 10 Jun 2011 11:13:27.725 : Connecting to s
erver ftps.tdbank.ca
ERROR [SSLSocket] 10 Jun 2011 11:13:27.850 : internalSocket() failed - closing socket : Server certificate cou
ld not be validated.
com.enterprisedt.net.puretls.cert.CertificateVerifyException: Server certificate could not be validated.
at com.enterprisedt.net.puretls.n.B(Unknown Source)
at com.enterprisedt.net.puretls.Z.B(Unknown Source)
at com.enterprisedt.net.puretls.n.E(Unknown Source)
at com.enterprisedt.net.puretls.i.G(Unknown Source)
at com.enterprisedt.net.puretls.SSLSocket.internalSocket(Unknown Source)
at com.enterprisedt.net.puretls.SSLSocket.<init>(Unknown Source)
at com.enterprisedt.net.ftp.ssl.SSLFTPClient.connect(Unknown Source)
at ftpstest.UseFTPSWithServerValidation.main(UseFTPSWithServerValidation.java:
112)


com.enterprisedt.net.puretls.cert.CertificateVerifyException: Server certificate could not be validated.
at com.enterprisedt.net.puretls.n.B(Unknown Source)
at com.enterprisedt.net.puretls.Z.B(Unknown Source)
at com.enterprisedt.net.puretls.n.E(Unknown Source)
at com.enterprisedt.net.puretls.i.G(Unknown Source)
at com.enterprisedt.net.puretls.SSLSocket.internalSocket(Unknown Source)
at com.enterprisedt.net.puretls.SSLSocket.<init>(Unknown Source)
at com.enterprisedt.net.ftp.ssl.SSLFTPClient.connect(Unknown Source)
at ftpstest.UseFTPSWithServerValidation.main(UseFTPSWithServerValidation.java:
112)
com.enterprisedt.net.puretls.cert.CertificateVerifyException: Server certificate could not be validated.
at com.enterprisedt.net.puretls.n.B(Unknown Source)
at com.enterprisedt.net.puretls.Z.B(Unknown Source)
at com.enterprisedt.net.puretls.n.E(Unknown Source)
at com.enterprisedt.net.puretls.i.G(Unknown Source)
at com.enterprisedt.net.puretls.SSLSocket.internalSocket(Unknown Source)
at com.enterprisedt.net.puretls.SSLSocket.<init>(Unknown Source)
at com.enterprisedt.net.ftp.ssl.SSLFTPClient.connect(Unknown Source)
at ftpstest.UseFTPSWithServerValidation.main(UseFTPSWithServerValidation.java:
112)
no avatar
User

EDT Support

Posts

905

Joined

Mon Apr 26, 2004 3:03 pm

by EDT Support » Sat Jun 11, 2011 6:34 am

There's a good chance that this is happening because the server is presenting a certificate that's different from the one you expect. You can connect and download the presented certificate by using the method SSLFTPClient.getServerCertificate(String,int,boolean). This method returns an SSLFTPCertificate object, which you can then write to a PEM file using the SSLFTPClient.writePEM() method. Once you have the certificate, try comparing it with the one you're currently using and also try connecting using that certificate.

-Hans (EnterpriseDT)
no avatar
User

Helen Lin

Posts

3

Joined

Fri Jun 10, 2011 3:48 am

by Helen Lin » Tue Jun 14, 2011 1:33 am

no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

by support2 » Tue Jun 14, 2011 8:52 am


Who is online

Users browsing this forum: No registered users and 101 guests

Powered by phpBB ® | phpBB3 Style by KomiDesign
cron