Home | History | Annotate | Download | only in util

Lines Matching refs:x509

24 X509* CertificateUtil::X509FromPEM(std::string pem) {
26 X509* x509 = PEM_read_bio_X509(bio, NULL, 0, NULL);
30 if (X509_cmp_current_time(X509_get_notBefore(x509)) > 0
31 || X509_cmp_current_time(X509_get_notAfter(x509)) < 0) {
33 X509_free(x509);
37 return x509;
40 std::string CertificateUtil::X509ToPEM(X509* x509) {
42 PEM_write_bio_X509(bio, x509);
86 X509* CertificateUtil::GenerateSelfSignedCert(EVP_PKEY* pkey,
89 X509* x509 = X509_new();
90 X509_set_version(x509, 2);
91 ASN1_INTEGER_set(X509_get_serialNumber(x509), 0);
92 X509_gmtime_adj(X509_get_notBefore(x509), 0);
93 X509_gmtime_adj(X509_get_notAfter(x509), (int64_t) 60 * 60 * 24 * days);
94 X509_set_pubkey(x509, pkey);
96 X509_NAME* name = X509_get_subject_name(x509);
100 X509_set_issuer_name(x509, name);
101 X509_sign(x509, pkey, EVP_sha256());
103 return x509;