如何检查 openssl c++如果字符串是证书,如果是,则该字符串是否是根证书
我正在 gcc 环境上工作。我需要实现两个函数:
1)检查给定字符串是否是证书的函数。
2) 检查给定字符串是否为根证书的函数。
我想使用openssl。
我怎样才能做到这一点?
I'm working on gcc environment. I need to implement two functions:
1) function that checks if a given string is a certificate.
2) function that checks if a given string is root certificate.
I want to use openssl.
how can I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
d2i_X509
及相关。从技术上讲,根证书是应用程序信任的任何证书,无需进一步验证。因此,哪些证书是根证书取决于您。按照惯例,根证书的颁发者名称和使用者名称相同。您可以使用
从 X509 证书获取颁发者和主题名称
X509_NAME *X509_get_subject_name(X509 *a);
X509_NAME *X509_get_issuer_name(X509 *a);
并将它们与
方法进行比较。
d2i_X509
and related.Technically, a root certificate is any certificate trusted by the application without further verification. So it is up to you as to which certificates are root certificates. By convention root certificates have their issuer and subject names identical. You can get the issuer and subject names from an X509 certificates with the
X509_NAME *X509_get_subject_name(X509 *a);
X509_NAME *X509_get_issuer_name(X509 *a);
and compare them with the
method.