add --capath and --cafile including insecure option

This commit is contained in:
John
2022-02-19 12:55:38 +01:00
parent a06a96d1df
commit ab97fc3299
5 changed files with 24 additions and 10 deletions
+1 -3
View File
@@ -142,9 +142,6 @@ bool SSLSocket::isValid() {
return time(nullptr) < m_until && !BIO_eof(m_bio);
}
// general switch for future insecure option
static const bool verifyPeer = true;
SSLSocket* SSLSocket::connect(const string& host, const uint16_t& port, bool https, int timeout, const char* caFile,
const char* caPath) {
BIO *bio = nullptr;
@@ -173,6 +170,7 @@ SSLSocket* SSLSocket::connect(const string& host, const uint16_t& port, bool htt
if (isError("ctx_new", ctx)) {
break;
}
bool verifyPeer = !caFile || strcmp(caFile, "#")!=0;
SSL_CTX_set_verify(ctx, verifyPeer ? SSL_VERIFY_PEER : SSL_VERIFY_NONE, nullptr);
if (verifyPeer) {
#if OPENSSL_VERSION_NUMBER >= 0x10101000L