相关疑难解决方法(0)

C中的x509证书验证

我有DER和PEM格式的证书,我的目标是检索Issuer和Subject的字段,并使用CA公钥验证证书,同时使用根公钥验证CA证书.我能够检索发行人和主题的所有细节,但无法验证证书.
使用的API:

x509 = d2i_X509_fp (fp, &x509); //READING DER Format
x509 = PEM_read_X509 (fp, &x509, NULL, NULL); //READING PEM Format
//to retrieve the Subject:
X509_NAME_oneline(X509_get_subject_name(x509), subject, sizeof (subject));
//to retrieve the Issuer:
X509_NAME_oneline(X509_get_issuer_name(x509), issuer, sizeof (issuer));

//To store the CA public key (in unsigned char *key) that will be used to verify the 
//certificate (in my case always sha1WithRSAEncryption):
RSA *x = X509_get_pubkey(x509)->pkey.rsa;
bn = x->n;
//extracts the bytes from public key & convert into unsigned char buffer
buf_len = …
Run Code Online (Sandbox Code Playgroud)

c openssl

7
推荐指数
2
解决办法
2万
查看次数

标签 统计

c ×1

openssl ×1