如何在C中验证X509证书 [英] How to verify a X509 certificate in C

查看:144
本文介绍了如何在C中验证X509证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有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.

谢谢 最好的问候.

推荐答案

请参见文档您需要使用X509_STORE_CTX_new创建证书存储. 然后使用X509_STORE_CTX_set_chain添加证书链.使用X509_STORE_CTX_trusted_stack添加受信任的根证书. 最后,添加要使用X509_STORE_CTX_set_cert进行验证的证书.

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屋!

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