add --capath and --cafile including insecure option
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -67,7 +67,7 @@ class SSLSocket {
|
||||
* @param port the port number.
|
||||
* @param https true for HTTPS, false for HTTP.
|
||||
* @param timeout the connect, send, and receive timeout in seconds, or 0 for blocking mode.
|
||||
* @param caFile the CA file to use (uses defaults if neither caFile nor caPath are set).
|
||||
* @param caFile the CA file to use (uses defaults if neither caFile nor caPath are set), or "#" for insecure.
|
||||
* @param caPath the path with CA files to use (uses defaults if neither caFile nor caPath are set).
|
||||
* @return the connected SSLSocket, or nullptr on error.
|
||||
*/
|
||||
@@ -122,7 +122,7 @@ class HttpClient {
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
* @param caFile the CA file to use (uses defaults if neither caFile nor caPath are set).
|
||||
* @param caFile the CA file to use (uses defaults if neither caFile nor caPath are set), or "#" for insecure.
|
||||
* @param caPath the path with CA files to use (uses defaults if neither caFile nor caPath are set).
|
||||
*/
|
||||
explicit HttpClient(const char* caFile = nullptr, const char* caPath = nullptr) :
|
||||
|
||||
Reference in New Issue
Block a user