mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
defer reading of certificates until the first SSL connection
This commit is contained in:
parent
b12571edd9
commit
e926155c82
@ -670,7 +670,7 @@ run_proxy_reading_header() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
bool HTTPChannel::
|
bool HTTPChannel::
|
||||||
run_setup_ssl() {
|
run_setup_ssl() {
|
||||||
_sbio = BIO_new_ssl(_client->_ssl_ctx, true);
|
_sbio = BIO_new_ssl(_client->get_ssl_ctx(), true);
|
||||||
BIO_push(_sbio, *_bio);
|
BIO_push(_sbio, *_bio);
|
||||||
|
|
||||||
if (downloader_cat.is_debug()) {
|
if (downloader_cat.is_debug()) {
|
||||||
@ -2120,8 +2120,9 @@ show_send(const string &message) {
|
|||||||
size_t start = 0;
|
size_t start = 0;
|
||||||
size_t newline = message.find('\n', start);
|
size_t newline = message.find('\n', start);
|
||||||
while (newline != string::npos) {
|
while (newline != string::npos) {
|
||||||
|
// Assume every \n is preceded by a \r.
|
||||||
downloader_cat.spam()
|
downloader_cat.spam()
|
||||||
<< "send: " << message.substr(start, newline - start + 1);
|
<< "send: " << message.substr(start, newline - start - 1) << "\n";
|
||||||
start = newline + 1;
|
start = newline + 1;
|
||||||
newline = message.find('\n', start);
|
newline = message.find('\n', start);
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,13 @@ HTTPClient::
|
|||||||
HTTPClient() {
|
HTTPClient() {
|
||||||
_http_version = HV_11;
|
_http_version = HV_11;
|
||||||
_verify_ssl = verify_ssl ? VS_normal : VS_no_verify;
|
_verify_ssl = verify_ssl ? VS_normal : VS_no_verify;
|
||||||
make_ctx();
|
_ssl_ctx = (SSL_CTX *)NULL;
|
||||||
|
|
||||||
|
// The first time we create an HTTPClient, we must initialize the
|
||||||
|
// OpenSSL library.
|
||||||
|
if (!_ssl_initialized) {
|
||||||
|
initialize_ssl();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -67,7 +73,7 @@ HTTPClient(const HTTPClient ©) {
|
|||||||
// function will copy them in a second.
|
// function will copy them in a second.
|
||||||
_http_version = HV_11;
|
_http_version = HV_11;
|
||||||
_verify_ssl = verify_ssl ? VS_normal : VS_no_verify;
|
_verify_ssl = verify_ssl ? VS_normal : VS_no_verify;
|
||||||
make_ctx();
|
_ssl_ctx = (SSL_CTX *)NULL;
|
||||||
|
|
||||||
(*this) = copy;
|
(*this) = copy;
|
||||||
}
|
}
|
||||||
@ -356,15 +362,15 @@ get_header(const URLSpec &url) {
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: HTTPClient::make_ctx
|
// Function: HTTPClient::get_ssl_ctx
|
||||||
// Access: Private
|
// Access: Public
|
||||||
// Description: Creates the OpenSSL context object. This is only
|
// Description: Returns the OpenSSL context object, creating it first
|
||||||
// called by the constructor.
|
// if needed.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void HTTPClient::
|
SSL_CTX *HTTPClient::
|
||||||
make_ctx() {
|
get_ssl_ctx() {
|
||||||
if (!_ssl_initialized) {
|
if (_ssl_ctx != (SSL_CTX *)NULL) {
|
||||||
initialize_ssl();
|
return _ssl_ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
_ssl_ctx = SSL_CTX_new(SSLv23_client_method());
|
_ssl_ctx = SSL_CTX_new(SSLv23_client_method());
|
||||||
@ -428,6 +434,8 @@ make_ctx() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return _ssl_ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -95,8 +95,10 @@ PUBLISHED:
|
|||||||
const string &body = string());
|
const string &body = string());
|
||||||
PT(HTTPChannel) get_header(const URLSpec &url);
|
PT(HTTPChannel) get_header(const URLSpec &url);
|
||||||
|
|
||||||
|
public:
|
||||||
|
SSL_CTX *get_ssl_ctx();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void make_ctx();
|
|
||||||
static void initialize_ssl();
|
static void initialize_ssl();
|
||||||
static int load_verify_locations(SSL_CTX *ctx, const Filename &ca_file);
|
static int load_verify_locations(SSL_CTX *ctx, const Filename &ca_file);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user