Tag: x509certificate

从byte 生成X509Certificate?

是否有可能从byte []生成一个java.security.cert.X509Certificate?

X509Certificate构造函数exception

//cert is an EF Entity and // cert.CertificatePKCS12 is a byte[] with the certificate. var certificate = new X509Certificate(cert.CertificatePKCS12, "SomePassword"); 从我们的数据库加载证书时,在我们的登台服务器(Windows 2008 R2 / IIS7.5)上,我们得到这个exception: System.Security.Cryptography.CryptographicException: An internal error occurred. at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr) at System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromBlob(Byte[] rawData, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx) at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromBlob(Byte[] rawData, Object password, X509KeyStorageFlags keyStorageFlags) 注意:这个问题不会发生在本地(Windows 7 / Casini)。 […]

.NET中的X509Certificate2和X509Certificate有什么区别?

两者有什么区别?

如何在C#中通过指纹查找证书

我正在使用此代码通过其指纹find证书。 证书存在于个人证书库中的证书pipe理器中,但是此代码没有find该证书。 请告诉我我在哪里做错了。 namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string certThumbPrint = "‎‎fe14593dd66b2406c5269d742d04b6e1ab03adb1"; X509Store certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser); // Try to open the store. certStore.Open(OpenFlags.ReadOnly); // Find the certificate that matches the thumbprint. X509Certificate2Collection certCollection = certStore.Certificates.Find(X509FindType.FindByThumbprint, certThumbPrint, false); certStore.Close(); // Check to see if our certificate was added […]

如何在Java中从X509Certificate中提取CN?

我正在使用SslServerSocket和客户端证书,并希望从客户端的X509Certificate的SubjectDN中提取CN。 目前我打电话给cert.getSubjectX500Principal().getName()但这当然给了我的客户端的总格式化的DN。 出于某种原因,我只是对CN=theclient部分感兴趣。 有没有办法提取这部分的DN,而不是自己parsingstring?

当我设置IIS池的LoadUserProfile时究竟发生了什么?

我遇到了以下问题。 我运行下面的代码 var binaryData = File.ReadAllBytes(pathToPfxFile); var cert = new X509Certificate2(binaryData, password); 在两个过程中。 其中一个进程在LOCAL_SYSTEM下运行,并且代码成功。 另一个运行在属于“用户”本地组的本地用户帐户下的IIS,在那里我得到以下exception: System.Security.Cryptography.CryptographicException Object was not found. at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr) at System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromBlob(Byte[] rawData, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx) at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromBlob(Byte[] rawData, Object password, X509KeyStorageFlags keyStorageFlags) at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData, String password) //my code here 所以我Googlesearch了一下,发现了一个类似的问题的答案 。 我试图为应用程序池启用LoadUserProfile ,现在它工作。 问题是当我设置LoadUserProfile时会发生什么,以及可能会产生什么后果。 我的意思是,如果这是一个“好”的东西,那么为什么它不是默认的“开”,为什么它在那里呢? […]

“X509Certificate2”加载pfx文件时发生“内部错误”

我试图使用自签名证书(C#): X509Certificate2 cert = new X509Certificate2( Server.MapPath("~/App_Data/myhost.pfx"), "pass"); 在一个共享的networking托pipe服务器,我得到一个错误: System.Security.Cryptography.CryptographicException: An internal error occurred. 堆栈跟踪结束 System.Security.Cryptography.CryptographicException. ThrowCryptogaphicException(Int32 hr) +33 System.Security.Cryptography.X509Certificates.X509Utils. _LoadCertFromFile(String fileName, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx) +0 System.Security.Cryptography.X509Certificates.X509Certificate. LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags) +237 System.Security.Cryptography.X509Certificates.X509Certificate2..ctor( String fileName, String password) +131 在我的开发机器上它加载好。 之所以我加载* .pfx不是* .cer文件,因为我需要一个私钥访问(cer文件加载好)。 我在这个开发系统上做了pfx: makecert -r -n "CN=myhost.com, E=admin@myhost.com" […]

如何使用OpenSSL生成带有SubjectAltName的自签名证书?

我试图用OpenSSL和SubjectAltName生成一个自签名证书。虽然我为证书生成了csr,但是我的猜测是我必须使用OpenSSL x509的v3扩展。 我在用 : openssl req -new -x509 -v3 -key private.key -out certificate.pem -days 730 有人可以帮助我的确切语法?

Unix时间戳“120314170138Z”中的“Z”是什么意思?

我有一个X.509证书有以下两个时间戳: ['validFrom'] = String(13) "120314165227Z" ['validTo'] = String(13) "130314165227Z" 后缀字符“Z”是什么意思。 它是否指定时区?

在Java KeyStore中导入私钥/公钥证书对

我使用以下步骤创build了一个新的Java密钥库,其中包含一对由Java(内部)服务器和TLS使用的私钥/公钥。 请注意,证书是自签名的: 1)用AES256生成密钥 openssl genrsa -aes256 -out server.key 1024 2)为CA生成证书请求 openssl req -x509 -sha256 -new -key server.key -out server.csr 3)生成自签名到期时间10年 openssl x509 -sha256 -days 3652 -in server.csr -signkey server.key -out selfsigned.crt 4)使用像KeyStoreExplorer这样的程序将一对(私钥和自签名证书)导入到一个新的JKS 这工作,但我想实现最后一步,而不使用GUI。 我知道如何只导入自签名证书: // create the keystore and import the public key. THIS WILL NOT IMPORT THE PRIVATE KEY SO THE KEYSTORE CAN'T BE […]