从X509 *获取主题和发行人信息 [英] Get subject and issuer information from the X509*
问题描述
我正在验证伺服器上的用户端凭证。
I am in process of verifying a client certificate on server.
我使用了SSL_CTX_set_verify,并有一个有效的回呼API,到期日和少数其他参数。我需要提取客户端证书的'Issued By'和'Issued To'值。
I have used the SSL_CTX_set_verify and have a valid callback API inside which i am validating the client certificate for expiry date and few other parameters.I need to extract the 'Issued By' and 'Issued To' values of the client certificate.
回调函数是这样的
int certificateVerificationCallBack(int preverify_ok, X509_STORE_CTX *ctx)
{
X509* cert = X509_STORE_CTX_get_current_cert(ctx);
}
我获得客户端证书详细信息填充到X509指针,获得到期日期(直接访问)。但我不能弄清楚什么OpenSSL API使用来获得'发布者'和'发布到'。
I am getting the client certificate details filled into the X509 pointer and am able to get the expiry date too(straight forward access). But i am not able to figure out what OpenSSL API to use to get the 'issued by' and 'issued to'.
推荐答案
如果您想要证书的主题名称和发行者名称,您需要使用 X509_get_subject_name 和 X509_get_issuer_name
API。这些采用X509指针并返回各自的名称。
If you want the subject name and issuer name of the certificate, you need to use the X509_get_subject_name and X509_get_issuer_name
APIs. These take the X509 pointer and return the respective names.
更多信息可以获得此处
这篇关于从X509 *获取主题和发行人信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!