如何在C中验证X509证书 [英] How to verify a X509 certificate in C
问题描述
我有X509格式的证书.这是一个函数中的输入参数. 我想做的就是验证证书的有效性. 怎么做到呢?
I have a certificate in X509 format. this a input parameters in a function. What I would like to do is to verify the validity of the certificate. How can it be done?
X509_verify_cert();
我找到了此功能,但是它不接受X509 *证书,它接受X509_store,而我只有X509.
I found this function, but this does not accept a X509* certificate, it accepts X509_store and I only have a X509.
谢谢 最好的问候.
推荐答案
You need to create a certificate store using X509_STORE_CTX_new. Then add certificate chain using X509_STORE_CTX_set_chain. Add trusted root certificate using X509_STORE_CTX_trusted_stack. Finally add certificate to be verified using X509_STORE_CTX_set_cert.
之后调用X509_verify_cert.
After that call X509_verify_cert.
我希望这可以帮助您开始.
I hope this will help you to start on this.
这篇关于如何在C中验证X509证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!