Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Unified Diff: net/ocsp/nss_ocsp.cc

Issue 10875059: Reduce the network timeout for NSS from 60 seconds to 15 seconds (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase to master Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ocsp/nss_ocsp.cc
diff --git a/net/ocsp/nss_ocsp.cc b/net/ocsp/nss_ocsp.cc
index 5abdd939d9e92a3fcecf336cd40b18a34329d103..a85a80db0db4ad9af8a2609053f653d9c95d88eb 100644
--- a/net/ocsp/nss_ocsp.cc
+++ b/net/ocsp/nss_ocsp.cc
@@ -12,6 +12,7 @@
#include <pthread.h>
#include <secerr.h>
+#include <algorithm>
#include <string>
#include "base/basictypes.h"
@@ -45,6 +46,10 @@ namespace {
pthread_mutex_t g_request_context_lock = PTHREAD_MUTEX_INITIALIZER;
URLRequestContext* g_request_context = NULL;
+// The default timeout for network fetches in NSS is 60 seconds. Choose a
+// saner upper limit for OCSP/CRL/AIA fetches.
+const int kNetworkFetchTimeoutInSecs = 15;
+
class OCSPRequestSession;
class OCSPIOLoop {
@@ -442,9 +447,14 @@ class OCSPServerSession {
path_and_query_string));
VLOG(1) << "URL [" << url_string << "]";
GURL url(url_string);
- return new OCSPRequestSession(
- url, http_request_method,
+
+ // NSS does not expose public functions to adjust the fetch timeout when
+ // using libpkix, so hardcode the upper limit for network fetches.
+ base::TimeDelta actual_timeout = std::min(
+ base::TimeDelta::FromSeconds(kNetworkFetchTimeoutInSecs),
base::TimeDelta::FromMilliseconds(PR_IntervalToMilliseconds(timeout)));
+
+ return new OCSPRequestSession(url, http_request_method, actual_timeout);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698