我想讓OpenSSL.net 1)創建一個密鑰對用於CA簽名和2)使用此CA創建和簽署證書。我設法創建了RSA/SHA1 X509CertificateAuthority,並創建了X509Request和密鑰,但是我遇到了實際簽名請求的問題。使用OpenSSL.net簽署證書的問題
'create the request and request key
Dim rsa As OpenSSL.Crypto.RSA = New OpenSSL.Crypto.RSA()
rsa.GenerateKeys(1024, 65569, Nothing, Nothing)
Dim req_key As OpenSSL.Crypto.CryptoKey = New OpenSSL.Crypto.CryptoKey(rsa)
Dim req_key_b As OpenSSL.Core.BIO = OpenSSL.Core.BIO.MemoryBuffer
req_key_b.Write(req_key.GetRSA.PrivateKeyAsPEM)
WriteBio(req_key_b, IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "req.key"))
'make the request
Dim req As OpenSSL.X509.X509Request = New OpenSSL.X509.X509Request(3, "CN=newcert", req_key)
Dim req_cert As OpenSSL.X509.X509Certificate = ca.ProcessRequest(req, Now, Now.AddDays(365))
'** ^^^ Exception on this line ^^^ ***
Dim req_cert_b As OpenSSL.Core.BIO = OpenSSL.Core.BIO.MemoryBuffer
req_cert.Write(req_cert_b)
WriteBio(req_cert_b, IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "req.crt"))
我正在上線的OpenSslException上面提到的,與消息
error:0606B06E:digital envelope routines:EVP_SignFinal:wrong public key type error:0D0C3006:asn1 encoding routines:ASN1_item_sign:EVP lib
任何想法?
我最終放棄了openSSL並改用了BouncyCastle。更好的文檔 – insertjokehere