| 1110 | } |
| 1111 | |
| 1112 | bool IsCa(const std::shared_ptr<X509>& cacert) |
| 1113 | { |
| 1114 | #if OPENSSL_VERSION_NUMBER >= 0x10100000L |
| 1115 | /* OpenSSL 1.1.x provides https://www.openssl.org/docs/man1.1.0/man3/X509_check_ca.html |
| 1116 | * |
| 1117 | * 0 if it is not CA certificate, |
| 1118 | * 1 if it is proper X509v3 CA certificate with basicConstraints extension CA:TRUE, |
| 1119 | * 3 if it is self-signed X509 v1 certificate |
| 1120 | * 4 if it is certificate with keyUsage extension with bit keyCertSign set, but without basicConstraints, |
| 1121 | * 5 if it has outdated Netscape Certificate Type extension telling that it is CA certificate. |
| 1122 | */ |
| 1123 | return (X509_check_ca(cacert.get()) == 1); |
| 1124 | #else /* OPENSSL_VERSION_NUMBER >= 0x10100000L */ |
| 1125 | BOOST_THROW_EXCEPTION(std::invalid_argument("Not supported on this platform, OpenSSL version too old.")); |
| 1126 | #endif /* OPENSSL_VERSION_NUMBER >= 0x10100000L */ |
| 1127 | } |
| 1128 | |
| 1129 | int GetCertificateVersion(const std::shared_ptr<X509>& cert) |
| 1130 | { |
no test coverage detected