即使指定了SHA2,Java Keytool也会创建SHA1证书

时间:2016-07-06 20:12:59

标签: ssl encryption cryptography certificate keytool

到目前为止主要用于学习目的,我正在尝试使用Java的keytool生成SHA2证书。但是,当我生成密钥时,它表示证书指纹是SHA1,而不是SHA2。

keytool -genkey -alias test_sha2_rsa_key -keyalg RSA -keysize 2048 -keystore .keystore -sigalg "SHA256withRSA"

这是我列出密钥时的结果。

keytool -list
Enter keystore password:

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

test_sha2_rsa_key, Jul 6, 2016, PrivateKeyEntry,
Certificate fingerprint (SHA1): DD:9E:55:B7:90:9F:91:6C:68:D3:5C:24:E7:D4:45:D1:7D:8C:3A:5A

我读错了,还是做错了?

1 个答案:

答案 0 :(得分:4)

SHA-1指纹是通过二进制(DER)编码证书计算的。它不包含在证书中,并且 - 正如Dave已经规定的那样 - 与request({ method: "POST", url: "https://api.bufferapp.com/1/oauth2/token.json", headers: { 'User-Agent': 'request', }, body: 'client_id=' + buffer_clientid + '&client_secret=' + buffer_secret + '&redirect_uri=' + redirectURI + '&code=' + tokencode + '&grant_type=authorization_code' }, function(error, response, body){ console.log(body); // return the output. response.end(); }) 上的签名无关(证书的一部分"要签署")。实际上,由于它在整个证书上,签名算法参考(OID)和签名本身也包含在指纹数据中。

请注意,使用SHA-1对证书进行指纹识别与使用SHA-1签署证书一样安全。这取决于指纹的使用方式,但原则上如果(或何时)SHA-1被破坏,这可能会引入漏洞。

相关问题