summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/net.gyp4
-rw-r--r--net/socket/ssl_client_socket_nss.cc6
-rw-r--r--net/socket/ssl_client_socket_nss.h4
-rw-r--r--net/socket/ssl_client_socket_nss_unittest.cc17
4 files changed, 28 insertions, 3 deletions
diff --git a/net/net.gyp b/net/net.gyp
index 7c897ce..d37b0f3 100644
--- a/net/net.gyp
+++ b/net/net.gyp
@@ -1138,8 +1138,9 @@
'socket/socks5_client_socket_unittest.cc',
'socket/socks_client_socket_pool_unittest.cc',
'socket/socks_client_socket_unittest.cc',
- 'socket/ssl_client_socket_unittest.cc',
+ 'socket/ssl_client_socket_nss_unittest.cc',
'socket/ssl_client_socket_pool_unittest.cc',
+ 'socket/ssl_client_socket_unittest.cc',
'socket/ssl_server_socket_unittest.cc',
'socket/tcp_client_socket_unittest.cc',
'socket/tcp_server_socket_unittest.cc',
@@ -1233,6 +1234,7 @@
'base/x509_util_nss_unittest.cc',
'base/cert_database_nss_unittest.cc',
'base/dnssec_unittest.cc',
+ 'socket/ssl_client_socket_nss_unittest.cc',
],
}, { # else !use_openssl: remove the unneeded files
'sources!': [
diff --git a/net/socket/ssl_client_socket_nss.cc b/net/socket/ssl_client_socket_nss.cc
index d2991ba..5925a6b 100644
--- a/net/socket/ssl_client_socket_nss.cc
+++ b/net/socket/ssl_client_socket_nss.cc
@@ -483,6 +483,12 @@ SSLClientSocketNSS::~SSLClientSocketNSS() {
// static
void SSLClientSocketNSS::ClearSessionCache() {
+ // Initialize the NSS SSL library in a threadsafe way. This also
+ // initializes the NSS base library.
+ EnsureNSSSSLInit();
+ if (!NSS_IsInitialized())
+ return;
+
SSL_ClearSessionCache();
}
diff --git a/net/socket/ssl_client_socket_nss.h b/net/socket/ssl_client_socket_nss.h
index 7b56844..4114fd7 100644
--- a/net/socket/ssl_client_socket_nss.h
+++ b/net/socket/ssl_client_socket_nss.h
@@ -22,6 +22,7 @@
#include "net/base/cert_verify_result.h"
#include "net/base/completion_callback.h"
#include "net/base/host_port_pair.h"
+#include "net/base/net_export.h"
#include "net/base/net_log.h"
#include "net/base/nss_memio.h"
#include "net/base/origin_bound_cert_service.h"
@@ -56,8 +57,7 @@ class SSLClientSocketNSS : public SSLClientSocket {
const SSLClientSocketContext& context);
virtual ~SSLClientSocketNSS();
- // For tests
- static void ClearSessionCache();
+ NET_EXPORT_PRIVATE static void ClearSessionCache();
// SSLClientSocket methods:
virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE;
diff --git a/net/socket/ssl_client_socket_nss_unittest.cc b/net/socket/ssl_client_socket_nss_unittest.cc
new file mode 100644
index 0000000..2e85d31
--- /dev/null
+++ b/net/socket/ssl_client_socket_nss_unittest.cc
@@ -0,0 +1,17 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/socket/ssl_client_socket_nss.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+
+// Verifies that SSLClientSocketNSS::ClearSessionCache can be called without
+// explicit NSS initialization.
+TEST(SSLClientSocketNSSTest, ClearSessionCache) {
+ SSLClientSocketNSS::ClearSessionCache();
+}
+
+} // namespace net