2012-06-28 95 views
2

當創建公私密鑰對和證書,通常我們看到,該證書是這樣的:如何解碼自簽名證書

 -----BEGIN CERTIFICATE----- 
     XXX 
     XXX 
     ... 
     XXX 
     -----END CERTIFICATE----- 

如果我理解正確的,證書應包含大量的信息如發行人,時間,算法,公鑰等

有人可以告訴我我們如何解碼這個證書的瀏覽器?

回答

0

要回答我自己的問題:它只是一個Base64編碼。

2

大多數編程語言都具有這樣的功能,或者您可以使用OpenSSL命令行實用程序。

例如,在PHP中,你可以使用openssl_x509_parse()功能,

這裏有一個list of OpenSSL commands用於獲取證書信息。大多數編程語言都可以讓你調用像openssl這樣的系統命令。

這裏的鏈接信息櫃面的頁面被刪除:

# Using the -text option will give you the full breadth of information. 
openssl x509 -text -in cert.pem 

# who issued the cert? 
openssl x509 -noout -in cert.pem -issuer 

# to whom was it issued? 
openssl x509 -noout -in cert.pem -subject 

# for what dates is it valid? 
openssl x509 -noout -in cert.pem -dates 

# the above, all at once 
openssl x509 -noout -in cert.pem -issuer -subject -dates 

# what is its hash value? 
openssl x509 -noout -in cert.pem -hash 

# what is its MD5 fingerprint? 
openssl x509 -noout -in cert.pem -fingerprint 

在這裏當上了貝寶API公鑰運行是-text完整信息選項的輸出:

Certificate: 
    Data: 
     Version: 3 (0x2) 
     Serial Number: 0 (0x0) 
     Signature Algorithm: sha1WithRSAEncryption 
     Issuer: C=US, ST=CA, L=Mountain View, O=PayPal Inc., OU=live_certs, CN=live_api/[email protected] 
     Validity 
      Not Before: Feb 13 10:13:15 2004 GMT 
      Not After : Feb 13 10:13:15 2035 GMT 
     Subject: C=US, ST=CA, L=Mountain View, O=PayPal Inc., OU=live_certs, CN=live_api/[email protected] 
     Subject Public Key Info: 
      Public Key Algorithm: rsaEncryption 
      RSA Public Key: (1024 bit) 
       Modulus (1024 bit): 
        00:c1:47:4e:dd:fc:44:cc:4b:5c:9c:8e:d9:29:92: 
        f8:d7:65:ef:64:fb:a0:a2:78:bb:8b:b0:fb:a6:b0: 
        9e:d0:0b:5a:1d:37:3d:ec:26:20:9b:b3:6c:02:d2: 
        72:c4:d2:e2:c6:68:4b:57:ca:72:20:46:a2:1d:75: 
        80:87:c7:cf:29:6f:91:d3:5e:fe:12:65:eb:af:d1: 
        1a:aa:e3:e6:b1:5b:d3:cb:00:00:13:53:cc:34:e2: 
        aa:a3:69:25:e0:6c:62:cf:dc:d9:a8:86:a3:3a:6d: 
        5f:64:65:9c:19:2d:1f:e4:94:36:90:1a:8d:6e:f6: 
        e0:db:f6:5a:f8:62:7f:ab:05 
       Exponent: 65537 (0x10001) 
     X509v3 extensions: 
      X509v3 Subject Key Identifier: 
       96:9F:7C:BB:C6:6F:17:BD:59:3F:52:D7:0A:1B:EC:10:D6:64:94:6B 
      X509v3 Authority Key Identifier: 
       keyid:96:9F:7C:BB:C6:6F:17:BD:59:3F:52:D7:0A:1B:EC:10:D6:64:94:6B 
       DirName:/C=US/ST=CA/L=Mountain View/O=PayPal Inc./OU=live_certs/CN=live_api/[email protected] 
       serial:00 

      X509v3 Basic Constraints: 
       CA:TRUE 
    Signature Algorithm: sha1WithRSAEncryption 
     81:5f:3a:56:9a:80:5a:e5:ef:5f:a3:ab:a3:8a:89:d6:d6:15: 
     21:3e:43:81:6a:44:eb:dd:80:83:8d:b6:1f:bc:91:22:bf:fd: 
     8f:f8:8a:1b:84:e1:89:af:ce:7e:5c:78:4d:d2:fe:20:52:41: 
     03:23:ca:f6:fe:b3:64:d6:6d:06:03:c1:ca:75:db:d3:8f:21: 
     b0:fd:7a:97:6b:e2:d2:4e:50:d8:92:a2:3c:3b:04:7c:18:46: 
     23:e1:e7:c4:b5:c4:69:45:80:71:57:c2:b1:01:6f:77:60:35: 
     b3:14:6b:eb:b8:a9:e7:2d:b0:c0:17:a5:51:e7:0f:dc:08:c9: 
     f9:87 
-----BEGIN CERTIFICATE----- 
MIIDgzCCAuygAwIBAgIBADANBgkqhkiG9w0BAQUFADCBjjELMAkGA1UEBhMCVVMx 
CzAJBgNVBAgTAkNBMR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