Friday, December 20, 2013

How to generate Certicate and read Certicate

1- Generate certicate hostname (d7.cc):

root@localhost # openssl req -new -batch -x509 -days 3650 -nodes -newkey rsa:1024 -out cert.pem -keyout privkey.pem -subj /CN="d7.cc"

root@localhost # ls
 cert.pem  privkey.pem

2- Read the certificate

root@localhost # openssl x509 -in cert.pem -text
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 9687928977999044826 (0x867270139ed8a0da)
    Signature Algorithm: sha1WithRSAEncryption
        Issuer: CN=d7.cc
        Validity
            Not Before: Dec 20 21:47:41 2013 GMT
            Not After : Dec 18 21:47:41 2023 GMT
        Subject: CN=d7.cc
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (1024 bit)
                Modulus:
                    00:98:39:97:bf:cd:a5:51:48:e0:6d:43:df:85:d7:
                    be:7b:3e:d6:5c:b1:18:42:68:6c:67:f1:42:ba:ff:
                    0c:4f:e8:44:53:fd:6d:11:89:3d:8e:09:f8:54:a4:
                    64:c6:b4:a1:dc:93:9a:75:67:4c:7e:f4:77:c7:ed:
                    aa:6d:6c:be:80:a7:d8:79:8f:55:36:19:0f:04:a4:
                    1c:3b:25:3d:b7:5a:46:be:c5:5e:60:cd:23:eb:bd:
                    73:19:32:b8:e8:c9:49:c2:9f:2e:75:53:75:cd:46:
                    52:0b:e0:7b:55:74:1a:18:98:a7:2c:97:68:b5:21:
                    bc:47:91:2f:5f:63:a0:81:e7
# app_*  : applications, these extensions usually register callbacks to handle specific messages.
                Exponent: 65537 (0x10001)
        X509v3 extensions:
            X509v3 Subject Key Identifier:
                C5:B3:ED:32:56:41:1D:8B:97:50:CC:4F:D8:7E:C9:30:9F:90:B6:D9
            X509v3 Authority Key Identifier:
                keyid:C5:B3:ED:32:56:41:1D:8B:97:50:CC:4F:D8:7E:C9:30:9F:90:B6:D9

            X509v3 Basic Constraints:
                CA:TRUE
    Signature Algorithm: sha1WithRSAEncryption
         23:63:02:90:14:8f:f1:71:3f:16:72:51:47:49:05:4b:2b:84:
         53:83:fa:a1:87:6b:b2:fd:0e:96:e3:b8:37:d3:80:1a:3f:c6:
         96:1a:30:70:22:5a:e5:1c:6b:c8:c8:3f:e4:55:21:fe:c5:50:
         f0:2f:41:0d:02:7e:eb:63:5e:a4:dd:4f:3e:85:0c:a4:06:ca:
         c0:7c:60:f0:71:3a:38:50:3d:00:69:dd:95:c1:60:5e:5d:1f:
         f4:01:01:19:7f:e5:74:67:63:9a:61:7a:5b:ed:ca:31:39:f3:
         74:1b:f3:e7:5e:32:5a:9e:f9:4c:1f:32:c5:f3:80:c1:e5:4b:
         74:99
-----BEGIN CERTIFICATE-----
MIIB7jCCAVegAwIBAgIJAIZycBOe2KDaMA0GCSqGSIb3DQEBBQUAMBAxDjAMBgNV
BAMMBWQ3LmNjMB4XDTEzMTIyMDIxNDc0MVoXDTIzMTIxODIxNDc0MVowEDEOMAwG
A1UEAwwFZDcuY2MwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAJg5l7/NpVFI
4G1D34XXvns+1lyxGEJobGfxQrr/DE/oRFP9bRGJPY4J+FSkZMa0odyTmnVnTH70
d8ftqm1svoCn2HmPVTYZDwSkHDslPbdaRr7FXmDNI+u9cxkyuOjJScKfLnVTdc1G
Ugvge1V0GhiYpyyXaLUhvEeRL19joIHnAgMBAAGjUDBOMB0GA1UdDgQWBBTFs+0y
VkEdi5dQzE/Yfskwn5C22TAfBgNVHSMEGDAWgBTFs+0yVkEdi5dQzE/Yfskwn5C2
2TAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBACNjApAUj/FxPxZyUUdJ
BUsrhFOD+qGHa7L9DpbjuDfTgBo/xpYaMHAiWuUca8jIP+RVIf7FUPAvQQ0Cfutj
XqTdTz6FDKQGysB8YPBxOjhQPQBp3ZXBYF5dH/QBARl/5XRnY5phelvtyjE583Qb
8+deMlqe+UwfMsXzgMHlS3SZ
-----END CERTIFICATE-----

No comments:

Post a Comment