Linux(openssl):X509_verify通过ca证书的public key验证证书的签名

/docs/man3.0/man3/X509_verify.html (openssl.org)

提供了方法用于通过ca证书的public key验证证书的签名

//verify_cert.hpp
#include 
#include 
#include 
#include 
 
using namespace std;
namespace fs = std::filesystem;
 
class CertVerify{
public:
    CertVerify(const fs::path& certFilePath, const fs::path& caFilePath) : m_certFilePath(certFilePath), m_caFilePath(caFilePath) {}
 
public:
    int doVerify()
    {
        if(m_certFilePath.string().length() == 0 || m_caFilePath.string().length() == 0)
        {
            return -1;
        }
        if(!fs::exists(m_certFilePath) || !fs::exists(m_caFilePath))
        {
            return -2;
        }
        shared_ptr certBio(BIO_new_file(m_certFilePat

你可能感兴趣的:(Linux开发,linux)