users@glassfish.java.net

Re: SSL connection client certificate?

From: <glassfish_at_javadesktop.org>
Date: Mon, 03 Mar 2008 04:05:45 PST

Can you use this method :
protected static final String SUBJECT_KEY_IDENTIFIER_OID = "2.5.29.14";

public byte[] getSubjectKeyIdentifier(X509Certificate cert) {
        byte[] subjectKeyIdentifier =
                cert.getExtensionValue(SUBJECT_KEY_IDENTIFIER_OID);
        if (subjectKeyIdentifier == null)
            return null;
        
        try {
            sun.security.x509.KeyIdentifier keyId = null;
            
            sun.security.util.DerValue derVal = new sun.security.util.DerValue(
                    new sun.security.util.DerInputStream(subjectKeyIdentifier).getOctetString());
            
            keyId = new sun.security.x509.KeyIdentifier(derVal.getOctetString());
            return keyId.getIdentifier();
        } catch (NoClassDefFoundError ncde) {
            byte[] dest = new byte[subjectKeyIdentifier.length-4];
            System.arraycopy(
                    subjectKeyIdentifier, 4, dest, 0, subjectKeyIdentifier.length-4);
            return dest;
        } catch (IOException e) {
            //log exception
            throw new RuntimeException(e);
        }

    }
[Message sent by forum member 'kumarjayanti' (kumarjayanti)]

http://forums.java.net/jive/thread.jspa?messageID=261967