@@ -56,8 +56,11 @@ using namespace std;
5656
5757
5858
59- Connect::Connect (const string &_url, string _method, int _timeout, const vector<X509Cert> &certs, const string &userAgentData, const string &version)
60- : method(std::move(_method))
59+ Connect::Connect (const string &_url, string_view _method, int _timeout, vector<X509Cert> _certs, string _userAgentData, string_view _version)
60+ : method(_method)
61+ , userAgentData(std::move(_userAgentData))
62+ , version(_version)
63+ , certs(std::move(_certs))
6164 , timeout(_timeout)
6265{
6366 DEBUG (" Connecting to URL: %s" , _url.c_str ());
@@ -128,6 +131,9 @@ Connect::Connect(const string &_url, string _method, int _timeout, const vector<
128131 SSL_CTX_set_options (ssl.get (), options);
129132#endif
130133 SSL_CTX_set_quiet_shutdown (ssl.get (), 1 );
134+ // TLS peer verification is performed only when pinned certificates are provided.
135+ // Without pinning, content-level crypto covers integrity: OCSP responses are signed
136+ // by the responder cert, TSA responses are CMS-signed, and TSL uses known public keys.
131137 if (!certs.empty ())
132138 {
133139 SSL_CTX_set_verify (ssl.get (), SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT , nullptr );
@@ -159,7 +165,7 @@ Connect::Connect(const string &_url, string _method, int _timeout, const vector<
159165 }
160166 }
161167
162- BIO_printf (d, " %s %s HTTP/%s\r\n " , method. c_str ( ), path.c_str (), version. c_str ( ));
168+ BIO_printf (d, " %.* s %s HTTP/%.* s\r\n " , STR_VIEW_FMT (method ), path.c_str (), STR_VIEW_FMT (version ));
163169 addHeader (" Connection" , " close" );
164170 if (port == " 80" || port == " 443" )
165171 addHeader (" Host" , host);
@@ -305,7 +311,7 @@ Connect::Result Connect::exec(initializer_list<pair<string_view,string_view>> he
305311 return r;
306312 string &location = r.headers [" location" ];
307313 string url = location.find (" ://" ) != string::npos ? std::move (location) : baseurl + location;
308- Connect c (url, method, timeout);
314+ Connect c (url, method, timeout, std::move (certs), std::move (userAgentData), version );
309315 c.recursive = recursive + 1 ;
310316 return c.exec (headers);
311317}
0 commit comments