Skip to content

Commit bd6edb6

Browse files
TheComputerGuy96kristelmerilain
authored andcommitted
Use HTTP 1.0 for OCSP responses
For some reason, the nsc.vrm.lt's OCSP responder responds really slowly (over 2 minutes) in HTTP 1.1 mode (so use the legacy 1.0 protocol for OCSP responses) Signed-off-by: Aida Jonikienė <tcg96nougat@gmail.com>
1 parent f177be4 commit bd6edb6

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/crypto/Connect.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ using namespace std;
5656

5757

5858

59-
Connect::Connect(const string &_url, string _method, int _timeout, const vector<X509Cert> &certs, const string &userAgentData)
59+
Connect::Connect(const string &_url, string _method, int _timeout, const vector<X509Cert> &certs, const string &userAgentData, const string &version)
6060
: method(std::move(_method))
6161
, timeout(_timeout)
6262
{
@@ -159,7 +159,7 @@ Connect::Connect(const string &_url, string _method, int _timeout, const vector<
159159
}
160160
}
161161

162-
BIO_printf(d, "%s %s HTTP/1.1\r\n", method.c_str(), path.c_str());
162+
BIO_printf(d, "%s %s HTTP/%s\r\n", method.c_str(), path.c_str(), version.c_str());
163163
addHeader("Connection", "close");
164164
if(port == "80" || port == "443")
165165
addHeader("Host", host);

src/crypto/Connect.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ class Connect
6161
};
6262

6363
Connect(const std::string &url, std::string method = "POST",
64-
int timeout = 0, const std::vector<X509Cert> &certs = {}, const std::string &userAgentData = {});
64+
int timeout = 0, const std::vector<X509Cert> &certs = {}, const std::string &userAgentData = {},
65+
const std::string &version = "1.1");
6566
~Connect();
6667
inline Result exec(std::initializer_list<std::pair<std::string_view,std::string_view>> headers,
6768
const std::vector<unsigned char> &data)

src/crypto/OCSP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ OCSP::OCSP(const X509Cert &cert, const X509Cert &issuer, const std::string &user
7979
if(!OCSP_request_add1_nonce(req.get(), nullptr, 32)) // rfc8954: SIZE(1..32)
8080
THROW_OPENSSLEXCEPTION("Failed to add NONCE to OCSP request.");
8181

82-
Connect::Result result = Connect(url, "POST", 0, {}, userAgent).exec({
82+
Connect::Result result = Connect(url, "POST", 0, {}, userAgent, "1.0").exec({
8383
{"Content-Type", "application/ocsp-request"},
8484
{"Accept", "application/ocsp-response"},
8585
{"Connection", "Close"},

0 commit comments

Comments
 (0)