Sunday, 5 July 2015

Export public key certificate from keystore

Use following command to export public key certificate from keystore.

Syntax
keytool -export -keystore key_store_file_name -alias certificate_name -file certificate_name.cer

To extract certificate1 from keystore.jks, use following command.

keytool -export -keystore /Users/harikrishna_gurram/keystore.jks -alias certificate1 -file Example.cer

$ keytool -export -keystore /Users/harikrishna_gurram/keystore.jks -alias certificate1 -file Example.cer
Enter keystore password: 
Certificate stored in file <Example.cer>

Use following command to view contents of Example.cer.

openssl x509 -inform der -in Example.cer -noout –text

$ openssl x509 -inform der -in Example.cer -noout -text
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 312551854 (0x12a129ae)
        Signature Algorithm: sha256WithRSAEncryption
        Issuer: C=IN, ST=Karnataka, L=Bangalore, O=Self learn Java, OU=Self learn Java, CN=Hari Krishna Gurram
        Validity
            Not Before: Jul  3 07:09:19 2015 GMT
            Not After : Jul 10 07:09:19 2015 GMT
        Subject: C=IN, ST=Karnataka, L=Bangalore, O=Self learn Java, OU=Self learn Java, CN=Hari Krishna Gurram
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
            RSA Public Key: (2048 bit)
                Modulus (2048 bit):
                    00:bb:23:ca:60:a1:64:05:cc:94:ea:be:3e:a1:84:
                    bb:ed:82:42:2e:58:4f:06:ec:6d:db:78:70:4d:7b:
                    0d:d9:17:fd:90:9e:56:3e:fc:02:f2:17:e1:89:03:
                    ff:0a:4e:c3:4c:b9:5d:b9:fb:1a:2b:ea:a5:c5:fb:
                    58:61:c7:7c:f8:44:29:dc:0a:93:fa:61:5c:e5:b5:
                    b2:f9:9c:0b:1b:52:32:53:28:7e:79:72:d5:62:2b:
                    f7:15:e9:8c:dd:8a:4a:42:27:51:1b:36:f3:8b:3b:
                    28:de:c5:30:6e:4e:50:d0:11:11:27:41:01:33:84:
                    a5:7b:2d:33:9b:64:bf:2e:c2:c4:0f:e0:3b:c4:a3:
                    2d:2f:de:46:4b:7b:ac:71:63:e4:13:a9:27:e8:6a:
                    2e:d8:55:ee:18:d3:f1:5d:1e:cf:3a:59:d9:9c:4d:
                    17:49:f5:47:da:a4:bb:6f:33:1f:7c:6b:51:9b:ff:
                    af:a6:d9:9d:c7:5a:94:09:7a:61:72:08:ea:18:83:
                    ab:57:f0:1d:e2:89:57:41:c5:cd:6e:4f:0f:f6:99:
                    d1:2b:c1:b9:e5:87:fb:4c:c8:5c:b3:4e:a9:d0:a2:
                    3a:8e:0b:67:b1:d7:6e:8f:c5:3e:bc:3e:2e:28:3b:
                    a2:31:4d:ab:9a:10:b8:97:43:78:9c:0a:46:03:cf:
                    66:3b
                Exponent: 65537 (0x10001)
        X509v3 extensions:
            X509v3 Subject Key Identifier: 
                AF:12:09:BA:52:E9:E2:DB:F7:92:BD:93:C2:31:FC:81:44:EA:7C:32
    Signature Algorithm: sha256WithRSAEncryption
        7e:4b:00:da:81:08:99:98:1e:d4:25:35:8f:90:3c:63:f2:80:
        69:f7:ea:bf:03:a9:af:1e:aa:7f:37:7b:49:b8:a8:a0:55:3e:
        ed:2d:74:46:dc:2c:1a:ee:fb:9c:af:0d:c7:7d:b2:0f:e6:e4:
        75:bb:11:4f:97:2d:51:78:de:93:50:d2:cc:cb:20:7f:39:a3:
        7f:8f:a4:da:9e:bc:65:cd:69:9a:40:e0:d8:ce:2b:46:95:e8:
        05:fc:a4:40:f5:71:53:9b:bd:37:6f:4a:ef:26:04:d5:8c:1f:
        79:b7:ef:97:f2:45:d4:bb:99:60:e5:3c:12:46:f2:00:35:09:
        e8:37:20:b7:19:af:d7:4f:d9:f9:f8:62:03:6d:f2:10:83:e1:
        49:49:2d:94:bf:44:8c:4b:b9:df:3e:6b:a6:16:1e:9d:56:4e:
        9c:db:52:a9:5c:2f:27:28:85:33:a7:87:a5:b3:57:e7:87:bf:
        dd:7d:4a:89:c9:b9:e8:ea:01:f0:37:a6:77:b0:1b:05:c5:37:
        fc:05:63:bc:de:ac:0b:74:56:b6:e2:20:5c:38:9f:b4:54:8c:
        8f:58:68:72:30:d6:5e:51:be:c6:7e:ce:3f:b5:13:a5:4b:9f:
        0e:55:1a:be:10:a4:90:a3:fd:dd:a3:db:25:23:fe:f6:99:4f:
        8f:cf:3f:72


No comments:

Post a Comment