supported config useSSL
This commit is contained in:
@@ -71,4 +71,12 @@ void ClientConfiguration::setReadTimeout(const long readTimeout) {
|
||||
readTimeout_ = readTimeout;
|
||||
}
|
||||
|
||||
bool ClientConfiguration::rejectUnauthorized() const {
|
||||
return rejectUnauthorized_;
|
||||
}
|
||||
|
||||
void ClientConfiguration::setRejectUnauthorized(const bool rejectUnauthorized) {
|
||||
rejectUnauthorized_ = rejectUnauthorized;
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -33,6 +33,7 @@ CoreClient::CoreClient(const std::string &servicename,
|
||||
: serviceName_(servicename), configuration_(configuration),
|
||||
httpClient_(new CurlHttpClient) {
|
||||
httpClient_->setProxy(configuration.proxy());
|
||||
httpClient_->setRejectUnauthorized(configuration.rejectUnauthorized());
|
||||
}
|
||||
|
||||
CoreClient::~CoreClient() { delete httpClient_; }
|
||||
|
||||
@@ -163,8 +163,13 @@ CurlHttpClient::makeRequest(const HttpRequest &request) {
|
||||
}
|
||||
|
||||
curl_easy_setopt(curlHandle_, CURLOPT_URL, url.c_str());
|
||||
curl_easy_setopt(curlHandle_, CURLOPT_SSL_VERIFYPEER, 1L);
|
||||
curl_easy_setopt(curlHandle_, CURLOPT_SSL_VERIFYHOST, 2L);
|
||||
if (rejectUnauthorized()) {
|
||||
curl_easy_setopt(curlHandle_, CURLOPT_SSL_VERIFYPEER, 1L);
|
||||
curl_easy_setopt(curlHandle_, CURLOPT_SSL_VERIFYHOST, 2L);
|
||||
} else {
|
||||
curl_easy_setopt(curlHandle_, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
curl_easy_setopt(curlHandle_, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||
}
|
||||
curl_easy_setopt(curlHandle_, CURLOPT_HEADERDATA, &response);
|
||||
curl_easy_setopt(curlHandle_, CURLOPT_HEADERFUNCTION, recvHeaders);
|
||||
|
||||
|
||||
@@ -36,4 +36,12 @@ void HttpClient::setProxy(const NetworkProxy &proxy) {
|
||||
proxy_ = proxy;
|
||||
}
|
||||
|
||||
bool HttpClient::rejectUnauthorized()const{
|
||||
return rejectUnauthorized_;
|
||||
}
|
||||
|
||||
void HttpClient::setRejectUnauthorized(const bool &rejectUnauthorized) {
|
||||
rejectUnauthorized_ = rejectUnauthorized;
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
Reference in New Issue
Block a user