提取客户证书&来自 .p12 文件的私钥 [英] Extracting client certificate & private key from .p12 file

查看:38
本文介绍了提取客户证书&来自 .p12 文件的私钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我如何使用

PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12); 

int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, STACK_OF(X509) **ca); 

任何文档参考也可以使用.

any documenatation reference will also work.

推荐答案

没有错误检查:

FILE *p12_file;
PKCS12 *p12_cert = NULL;
EVP_PKEY *pkey;
X509 *x509_cert;
STACK_OF(X509) *additional_certs = NULL;

p12_file = fopen("foo.p12", "rb");
d2i_PKCS12_fp(p12_file, &p12_cert);
fclose(p12_file);

PKCS12_parse(p12_cert, "password", &pkey, &x509_cert, &additional_certs);

私钥现在在 pkey 中,证书在 x509_cert 中,任何其他证书在 additional_certs 中.

The private key is now in pkey, the certificate in x509_cert and any additional certificates in additional_certs.

这篇关于提取客户证书&来自 .p12 文件的私钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆