将 X.509 证书存储在 C 字符串中并将其加载到 SSL_CTX 对象中?
我对 openssl 还很陌生。到目前为止,我已经浏览了 IBM 和 HP 提供的教程,并获得了一些有关如何使用 openssl API 的实践。
我的项目是关于使用加载了数字证书的 USB 安全内存令牌通过客户端浏览器上的 ActiveX 控件来验证客户端的身份。现在的问题是供应商提供的令牌库仅支持从令牌读取字符串和向令牌写入字符串。但是,我只知道如何使用 SSL_CTX_load_verify_locations()
或 SSL_CTX_use_certificate_file()
函数从文件加载证书。
我唯一能想到的就是将 BEGIN X509 CERTIFICATE 和 END X509 CERTIFICATE 之间的大块加密内容写入令牌并将其作为字符串读出。现在我真的需要一些帮助来将此字符串加载到 openssl 中的 SSL_CTX
对象 ctx
中。
顺便问一下,BEGIN X509 CERTIFICATE
和END X509 CERTIFICATE
之间的长内容是否包含所谓的公钥和除私钥之外的其他信息(例如到期日期)?如果我错了,请纠正我:)
任何帮助将不胜感激!
禅宗
I'm pretty new to openssl. So far I've gone through tutorials offered by IBM and HP and got some practices about how to use openssl APIs.
My project is about using a USB security memory token loaded with a digitial certificate to verify the identity of a client via an ActiveX control on the client's browser. Now the problem is that the vendor-provided library for the token only support reading and writing strings from and to the token. However, I only know how to load a certificate from a file with SSL_CTX_load_verify_locations()
or SSL_CTX_use_certificate_file()
functions.
The only thing I can think of is writing the large chunk of encrypted stuff between BEGIN X509 CERTIFICATE
and END X509 CERTIFICATE
to the token and read it out as a string. Now I really need some help to load this string into SSL_CTX
object ctx
in openssl.
BTW, does the long stuff between BEGIN X509 CERTIFICATE
and END X509 CERTIFICATE
contain the so-called public key and other info (such as expiration date) except private key? Please correct me if I'm wrong :)
Any help will be much appreciated!
Z.Zen
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您可以在令牌中读取和写入任意二进制 blob,那么您只需以 ASN1 格式存储证书和私钥,然后使用
SSL_CTX_use_certificate_ASN1()
和SSL_CTX_use_PrivateKey_ASN1()
加载它们即可代码>(按顺序)。请注意,您需要同时执行这两项操作,因为证书不存储私钥;它必须单独存放。If you can read and write arbitrary binary blobs to the token, then you can just store the certificate and private key in ASN1 format, then load them with
SSL_CTX_use_certificate_ASN1()
andSSL_CTX_use_PrivateKey_ASN1()
(in that order). Note that you need to do both, because a certificate does not store the private key; it must be stored separately.