简体   繁体   English

使用具有多个证书和私钥的PEM文件

[英]Using PEM file with multiple certificate and Private Key

I have a .PEM file that contains a private key and somehow it has 3 sets of certificates. 我有一个.PEM文件,其中包含一个私钥,并以某种方式包含3组证书。 I'm new to certificates and cant figure out how to import it to my code to be able to use it as authenticate to access clients web service. 我是证书的新手,无法弄清楚如何将其导入到我的代码中,以便能够将其用作访问客户端Web服务的身份验证。

Bag Attributes
    localKeyID: 94 7D DF 3D A7 A5 8D 3F FF 73 B5 CF 44 96 4F FC DC DC 51 BB 
    friendlyName: Company UAT Client SSL Certificate
Key Attributes: <No Attributes>
-----BEGIN PRIVATE KEY-----
-----END PRIVATE KEY-----
Bag Attributes
    localKeyID: 94 7D DF 3D A7 A5 8D 3F FF 73 B5 CF 44 96 4F FC DC DC 51 BB 
    friendlyName: Company UAT Client SSL Certificate
subject=/emailAddress=ljpclat@aaaa.com.ph/UID=002/CN=Company UAT Client SSL Certificate/OU=TCMG/O=AAAA/C=PH
issuer=/CN=AAAA Company API UAT CA/OU=Information Security/O=AAAA/C=PH
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
Bag Attributes
    friendlyName: AAAA Root CA
subject=/CN=AAAA Root CA/OU=Information Security/O=AAAA/C=PH
issuer=/CN=AAAA Root CA/OU=Information Security/O=AAAA/C=PH
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
Bag Attributes
    friendlyName: Name CA
subject=/CN=Subject CA/OU=Information Security/O=AAAA/C=PH
issuer=/CN=AAAA Root CA/OU=Information Security/O=AAAA/C=PH
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----

I have tried to use BouncyCastle - Org.BouncyCastle.X509 for C# but whenever i tried to access clients web service, I got Error (400) Bad Request. 我曾尝试将BouncyCastle-Org.BouncyCastle.X509用于C#,但是每当尝试访问客户端Web服务时,都会收到错误(400)错误请求。

I found a way to resolve my issue by converting PEM file into PFX/PKCS#12 format using openssl (or you can visit - https://www.sslshopper.com/ssl-converter.html if you dont have one installed) and then importing my certificate using X509Certificate2 in my code. 我找到了一种方法,通过使用OpenSSL的PEM文件转换成PFX / PKCS#12格式来解决我的问题(或者您可以访问- https://www.sslshopper.com/ssl-converter.html如果你没有安装)和然后在代码中使用X509Certificate2导入我的证书。 And everything else I based here - https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.x509certificates.x509certificate2.import?view=netframework-4.8 以及我在此处基于的所有其他内容-https: //docs.microsoft.com/zh-cn/dotnet/api/system.security.cryptography.x509certificates.x509certificate2.import?view=netframework - 4.8

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 X509Certificate2 的 .pem 私钥 - .pem private key to X509Certificate2 如何在 C# 中使用 .pem 文件中的私钥对值进行哈希处理 - how to hash the value using private key in .pem file in C# 在 android/iOS Keystore C# 上存储私钥和证书 (.pem) - Storing private key and certificate (.pem) on android/iOS Keystore C# 使用带有密码私钥的RSA解密消息使用C#中的pem文件 - Decrypt message using RSA with password private key using pem file in C# 读取PEM格式的RSA私钥并从证书中读取公钥 - Reading RSA Private Key in PEM format And Reading public Key from certificate 使用 PEM 私钥并使用 RSACryptoServiceProvider 和 SHA1 算法对文本进行签名 - Sign a text with PEM private key and using RSACryptoServiceProvider and SHA1 algorithm 如何将SSL证书从PEM转换为DER并保留私钥? - How can I convert a SSL certificate from PEM to DER and keep the private key? 使用代码在证书的私钥上设置权限 - Setting permissions on private key for a certificate using code 使用BouncyCastle和私有PEM文件的RSA解密不起作用 - RSA Decryption using BouncyCastle with private PEM file not working 使用预先存在的私钥对文件签名以创建证书(C#) - Using a pre-existing private key to sign file to create a certificate (C#)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM