directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r928378 - /directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/StudioKeyStoreManager.java
Date Sun, 28 Mar 2010 11:55:15 GMT
Author: seelmann
Date: Sun Mar 28 11:55:15 2010
New Revision: 928378

URL: http://svn.apache.org/viewvc?rev=928378&view=rev
Log:
Fix for DIRSTUDIO-642 (ADS does not remember the certificate if two certificates are used
for the same server):
o use SHA-1 hash as alias

Modified:
    directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/StudioKeyStoreManager.java

Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/StudioKeyStoreManager.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/StudioKeyStoreManager.java?rev=928378&r1=928377&r2=928378&view=diff
==============================================================================
--- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/StudioKeyStoreManager.java
(original)
+++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/StudioKeyStoreManager.java
Sun Mar 28 11:55:15 2010
@@ -32,6 +32,8 @@ import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.List;
 
+import org.apache.commons.codec.digest.DigestUtils;
+
 
 /**
  * A wrapper around {@link KeyStore}.
@@ -226,8 +228,11 @@ public class StudioKeyStoreManager
 
     private void addToKeyStore( X509Certificate certificate, KeyStore keyStore ) throws Exception
     {
-        String alias = certificate.getSubjectX500Principal().getName();
-        keyStore.setCertificateEntry( alias, certificate );
+        // The alias is not relevant, it just needs to be an unique identifier.
+        // The SHA-1 hash of the certificate should be unique.
+        byte[] encoded = certificate.getEncoded();
+        String shaHex = DigestUtils.shaHex( encoded );
+        keyStore.setCertificateEntry( shaHex, certificate );
     }
 
 



Mime
View raw message