Setting client and server certificates |
When establishing a connection you may define any optional client certificates that should be used for authentication purposes when establishing an SSL connection. In addition you may define any optional server certificates that should be validated against to ensure that the server you are communicating with this the server you are expecting. Client and server certificates should be stored in separate Java keystore files and protected using a keystore password.
Existing certificates may be imported into a Java keystore using the keytool.exe utility provided with the JDK.
Example
keytool.exe -import -file x509.cer -keystore your_store_name
The example above imports the certificate x509.cer into a keystore named your_store_name
Provided you have existing keystores you may set the client and server certificates using the Ftps#setClientCertificates and Ftps#setServerCertificates methods respectively.
Example
// set client certificates ftps.setClientCertificates("c:/certs/client_keystore","secret");
// set server certificates ftps.setServerCertificates("c:/certs/server_keystore","secret"); |