geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vamsic...@apache.org
Subject svn commit: r472509 - /geronimo/server/branches/1.1/modules/security/src/java/org/apache/geronimo/security/keystore/FileKeystoreInstance.java
Date Wed, 08 Nov 2006 14:58:31 GMT
Author: vamsic007
Date: Wed Nov  8 06:58:31 2006
New Revision: 472509

URL: http://svn.apache.org/viewvc?view=rev&rev=472509
Log:
GERONIMO-2431 generateCSR reverses the attribute sequence in subject name

Modified:
    geronimo/server/branches/1.1/modules/security/src/java/org/apache/geronimo/security/keystore/FileKeystoreInstance.java

Modified: geronimo/server/branches/1.1/modules/security/src/java/org/apache/geronimo/security/keystore/FileKeystoreInstance.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/1.1/modules/security/src/java/org/apache/geronimo/security/keystore/FileKeystoreInstance.java?view=diff&rev=472509&r1=472508&r2=472509
==============================================================================
--- geronimo/server/branches/1.1/modules/security/src/java/org/apache/geronimo/security/keystore/FileKeystoreInstance.java
(original)
+++ geronimo/server/branches/1.1/modules/security/src/java/org/apache/geronimo/security/keystore/FileKeystoreInstance.java
Wed Nov  8 06:58:31 2006
@@ -39,6 +39,7 @@
 import java.security.SignatureException;
 import java.security.UnrecoverableKeyException;
 import java.security.cert.Certificate;
+import java.security.cert.CertificateEncodingException;
 import java.security.cert.CertificateException;
 import java.security.cert.CertificateFactory;
 import java.security.cert.X509Certificate;
@@ -67,8 +68,11 @@
 import org.apache.geronimo.management.geronimo.KeystoreInstance;
 import org.apache.geronimo.management.geronimo.KeystoreIsLocked;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
+import org.apache.geronimo.util.asn1.ASN1InputStream;
+import org.apache.geronimo.util.asn1.ASN1Sequence;
 import org.apache.geronimo.util.asn1.ASN1Set;
 import org.apache.geronimo.util.asn1.DEROutputStream;
+import org.apache.geronimo.util.asn1.x509.X509CertificateStructure;
 import org.apache.geronimo.util.asn1.x509.X509Name;
 import org.apache.geronimo.util.encoders.Base64;
 import org.apache.geronimo.util.jce.PKCS10CertificationRequest;
@@ -334,7 +338,16 @@
 
     private String generateCSR(X509Certificate cert, PrivateKey signingKey) throws InvalidKeyException,
NoSuchAlgorithmException, NoSuchProviderException, SignatureException, KeyStoreException,
IOException {
         String sigalg = cert.getSigAlgName();
-        X509Name subject = new X509Name(cert.getSubjectDN().toString());
+        X509Name subject;
+        try{
+            ASN1InputStream ais = new ASN1InputStream(cert.getEncoded());
+            X509CertificateStructure x509Struct = new X509CertificateStructure((ASN1Sequence)ais.readObject());
+            ais.close();
+            subject = x509Struct.getSubject();
+        } catch(CertificateEncodingException e) {
+            log.warn(e.toString()+" while retrieving subject from certificate to create CSR.
 Using subjectDN instead.");
+            subject = new X509Name(cert.getSubjectDN().toString());
+        }
         PublicKey publicKey = cert.getPublicKey();
         ASN1Set attributes = null;
 



Mime
View raw message