如何获得证书的SHA256指纹? SHA 256证书有两个指纹,我可以检索主指纹而不是SHA256。如何获取SHA256证书指纹?
6
A
回答
0
public static String GetSha2Thumbprint(X509Certificate2 cert)
{
Byte[] hashBytes;
using (var hasher = new SHA256Managed())
{
hashBytes = hasher.ComputeHash(cert.RawData);
}
string result = BitConverter.ToString(hashBytes)
// this will remove all the dashes in between each two haracters
.Replace("-", string.Empty).ToLower();
return result;
}
After getting the Hashbytes , you have to do the bit convertion.
此信息对我也有帮助。 Hashing text with SHA-256 at Windows Forms
1
如果你想获得证书的SHA256指纹,你必须做一些手动工作。内置Thumbprint属性仅为SHA1。
呦必须使用SHA256 class和计算散列以上证书的内容:
using System;
using System.Linq;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
namespace MyNamespace {
class MyClass {
public static String GetSha2Thumbprint(X509Certificate2 cert) {
Byte[] hashBytes;
using (var hasher = new SHA256Managed()) {
hashBytes = hasher.ComputeHash(cert.RawData);
}
return hashBytes.Aggregate(String.Empty, (str, hashByte) => str + hashByte.ToString("x2"));
}
}
}
,如有必要,你这个代码转换为一个扩展方法。
相关问题
- 1. 如何为Branch.io提取Sha256 Cert指纹
- 2. 从证书获取Sha256公钥
- 3. 如何获取SHA1签名证书指纹?
- 4. 当webview onReceivedSslError被调用时,如何获取证书指纹
- 5. 如何从p12证书中获取SHA1指纹?
- 6. 如何获取发行人证书的指纹或公钥?
- 7. 如何在openssl中创建sha256指纹
- 8. PHP SSL证书指纹
- 9. hgrc中的SHA256指纹
- 10. jsrsasign - 如何提取x.509证书的指纹?
- 11. 如何从PHP路径中读取证书的指纹
- 12. 从命令行获取HTTPS服务器的证书指纹?
- 13. 尝试获取调试证书的MD5指纹,出现错误
- 14. 在Windows 7上获取HTTPS服务器的证书指纹?
- 15. 从powershell中的目录获取ssl证书指纹
- 16. 从Android应用程序获取证书指纹
- 17. 生成密钥库但只获取SHA1证书,我想要SHA256证书?
- 18. 如何在Android Studio中获取SHA-1指纹证书的发布模式?
- 19. Weblogic 10.3.3和SSL SHA256证书
- 20. 如何获得MD5认证指纹
- 21. 无法通过指纹找到证书
- 22. 拉的变化:bitbucket.org证书指纹SSH
- 23. Smartgit证书的SHA指纹不匹配
- 24. Android MD5 SDK指纹调试证书
- 25. 从签名证书指纹创建SecurityKey
- 26. 在C中打开SSL证书指纹
- 27. keytool和openssl证书指纹不匹配
- 28. 证书指纹出口后不匹配
- 29. SSL通配符证书指纹
- 30. 如何在Android Studio中获取我的Android指纹验证码
在Windows上,signtool程序允许将2个x509证书添加到文件中以获得authenticode散列。第一个证书是SHA1证书 - 用于向后兼容。然后有一个未认证的属性,它具有第二个SHA 256证书。因此,我想要访问/读取SHA 256指纹?2指纹 – mksteve
?您能否帮助我使用Class或Property(使用C#)?谢谢你回复 – Mahadev
你能解释一下你的任务吗?目前还不清楚你想获得SHA256指纹的地方?从证书本身?签名的内容?其他??? – Crypt32