commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve Cole" <sc...@camsbycbs.com>
Subject Re: org.apache.commons.net.ftp.FTPSClient question
Date Thu, 05 Feb 2009 15:35:16 GMT
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" <scole@camsbycbs.com>
To: <user@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


Mime
View raw message