You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Steve Cole <sc...@camsbycbs.com> on 2009/02/03 22:19:55 UTC
org.apache.commons.net.ftp.FTPSClient question
How to do I set the keystore used for client and server certifcate authentication? Can I just set these System properties or do I need actually set the KeyManager and TrustManager in FTPSClient?
System.setProperty("javax.net.ssl.trustStore",trustStore);
System.setProperty("javax.net.ssl.trustStoreType",trustStoreType);
System.setProperty("javax.net.ssl.trustStorePassword",trustStorePassword);
System.setProperty("javax.net.ssl.keyStore",keyStore);
System.setProperty("javax.net.ssl.keyStoreType",keyStoreType);
System.setProperty("javax.net.ssl.keyStorePassword",keyStorePassword);
Thanks,
Steve
Re: org.apache.commons.net.ftp.FTPSClient question
Posted by Steve Cole <sc...@camsbycbs.com>.
I figured it out, but here's what I did for anyone else this may help...
KeyStore keyStore = KeyStore.getInstance(keyStoreType,
keyStoreProvider);
keyStore.load(new
FileInputStream(keyStoreFilename),keyStorePassword.toCharArray());
KeyManagerFactory keyManagerFactory =
KeyManagerFactory.getInstance(keyStoreAlgorithm);
keyManagerFactory.init(keyStore,keyStorePassword.toCharArray());
KeyManager[] keyManagers = keyManagerFactory.getKeyManagers();
if (keyManagers.length == 0){
throw new Exception("No KeyManager found");
}else if (keyManagers.length > 1){
// I built the keystore and I'm only expecting 1 KeyManager,
// your implementation may differ
throw new Exception(keyManagers.length + " KeyManagers found.
Expected 1");
}
ftpsClient.setKeyManager(keyManagers[0]);
----- Original Message -----
From: "Steve Cole" <sc...@camsbycbs.com>
To: <us...@commons.apache.org>
Sent: Tuesday, February 03, 2009 4:19 PM
Subject: org.apache.commons.net.ftp.FTPSClient question
How to do I set the keystore used for client and server certifcate
authentication? Can I just set these System properties or do I need actually
set the KeyManager and TrustManager in FTPSClient?
System.setProperty("javax.net.ssl.trustStore",trustStore);
System.setProperty("javax.net.ssl.trustStoreType",trustStoreType);
System.setProperty("javax.net.ssl.trustStorePassword",trustStorePassword);
System.setProperty("javax.net.ssl.keyStore",keyStore);
System.setProperty("javax.net.ssl.keyStoreType",keyStoreType);
System.setProperty("javax.net.ssl.keyStorePassword",keyStorePassword);
Thanks,
Steve
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org