diff options
author | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-06 06:22:22 +0000 |
---|---|---|
committer | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-06 06:22:22 +0000 |
commit | 4c8346f5c8cb8aee75e24ee52e691bc5870557e2 (patch) | |
tree | 8a07f33e774a9afd1ea4c9cfa3f781385a713654 | |
parent | 79ee65390e6fb5d2cb306e0d3f3092a3b83e0609 (diff) | |
download | chromium_src-4c8346f5c8cb8aee75e24ee52e691bc5870557e2.zip chromium_src-4c8346f5c8cb8aee75e24ee52e691bc5870557e2.tar.gz chromium_src-4c8346f5c8cb8aee75e24ee52e691bc5870557e2.tar.bz2 |
SSLClientSocketNSS::ClearSessionCache should initialize
NSS implicitly before calling the NSS function
SSL_ClearSessionCache.
Remove the stale comment that
SSLClientSocketNSS::ClearSessionCache is only for tests.
R=mattm@chromium.org
BUG=105431
TEST=net_unittests --gtest_filter=SSLClientSocketNSSTest.ClearSessionCache
Review URL: http://codereview.chromium.org/8816002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113125 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/net.gyp | 4 | ||||
-rw-r--r-- | net/socket/ssl_client_socket_nss.cc | 6 | ||||
-rw-r--r-- | net/socket/ssl_client_socket_nss.h | 4 | ||||
-rw-r--r-- | net/socket/ssl_client_socket_nss_unittest.cc | 17 |
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 |