首页 > 编程知识 正文

openssl 单向认证 源码,51虚拟机激活码

时间:2023-05-03 09:13:25 阅读:165280 作者:4943

首先在网上搜索出来的OpenSSL解析证书大多是命令行工具的操作,也有通过C实现的,使用的版本比较旧,很多接口都发生了变化。 组织了基于OpenSSL1.1. 1版的分析X509证书的实现。

接口引用

QSslCertificate接口基于标准c实现相似接口,不依赖Qt,支持RSA和SM2证书信息分析、PFX、P7B证书分析、证书链分析、证书验证等

具体接口如下。

# ifndef x509 certificate _ h # define x509 certificate _ h # include string # include vector # include map # include memory # ifdefed _ win64|| _ win64 _|defined|win32|| defined | _ _ win32 dfi neq _ decl _ export _ declspec (dll export ) defineq_Decl_import_declspec ) dllimport ) #else# dfi neq _ decl _ export _ attribute _ ((visibility ) ' default ' ) (defineq_decl_import_attribute ) ) ) e x509 certificate _ exportq _ decl_export#else # define x509 certificate ) decl _ export # else ) define x509 certificate cate cte cled class x509认证扩展; class x509 certificate extension _ p; class x509 certificate _ export x509 certificate { public : x509 certificate (; x509certificate(constchar*cert,int len ); x509认证(const x509认证器); enum HashType { Hash_Sha1,Hash_Sha256,Hash_SM3 }; enum SubjectInfo { Organization,CommonName,LocalityName,OrganizationalUnitName,CountryName,StateOrProvinceName,distion bool operator==(const x509 certificate other ) const; 在线布尔操作器!=(constx509certificateother ) const { return! operator==(other ) } bool isNull () const; void *handle () const; int version () const; 字符串序列编号() const; 字符串子() const; 字符串子对象(subjectinfo ) const; 字符串子显示() const; 字符串issuer () const; stringissuerinfo (子信息用户) const; 字符串issuerdisplyname () const; 字符串not befor () const; string notAfter () const; 字符串诊断(hashtypetype ) const; 字符串公共密钥值() const; 字符串公共密钥() const; 字符串信号类型() const; 字符串符号值() const; vector x509 certificateextensionextensions () const; string toDer () const; string toPem () const; 字符串文本() const; staticboolimportpkcs12 (const char * pfx文件,int len,char *priKey,int priKeyLen,X509Certificate *x509Cert,vector x509 staticvectorx 509认证*分离(conststringchains ); //onlypemstaticintverify (const x509 certificateusercert,vector x509 certificatecertificatechain ); staticvectorx 509认证系统缓存(; private : shared _ ptr x509 certificate _ p; friend class X509Certificate_p; (; class x509 certificate _ export x509 certificate extension { public 3360 x509 certificate extension (enum ext method { ext _ string,string bool isCritical () const; bool isSupported () const; 字符串名称() const; string oid () const; 字符串值() const; 导出方法类型() const; 字符串状态()常量; vectorstring toVector () const; 多字符串,字符串到映射() const; private : x509 certificate extension _ p * p=nullptr; friend class x509认证; (; #endif //X509CERTIFICATE_H具体的代码实际上被放置在github中。 其中(顺便寻求Start ),整个项目包含一个测试接口的项目和生成共享库的项目是Qt项目。 当然,实现的源代码不依赖于Qt,也可以构建其他项目。

OpenSSL是依赖于Windows版本提供的,缺省情况下使用静态链接。 由于OpenSSL非常庞大,所以X509只是其中的一小部分,静态链接的方式更好。 Windows采用静态链接方法,因为它有现成的库。 在Linux上必须安装libssl-dev软件包,采用动态链接方式,必须通过静态链接自行编译。 我们测试了它在Windows和Linux上都可以正常使用。 理论上如果可以使用OpenSSL,也可以在其他平台上使用,所以需要单独进行测试。

整个接口结构引用Qt的p指针和q指针的方式,即实现的类和接口类是分离的,希望满足C的二进制兼容性,没有具体测试。

最后,自己的水平有限,无论是代码结构还是代码实现,其中都或多或少存在一些问题。 欢迎大家指出

参考资料:

1 .操作认证

2.Qt QSslCertificate源代码

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。