diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /security/manager/ssl/WeakCryptoOverride.cpp | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | uxp-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz |
Add m-esr52 at 52.6.0
Diffstat (limited to 'security/manager/ssl/WeakCryptoOverride.cpp')
-rw-r--r-- | security/manager/ssl/WeakCryptoOverride.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/security/manager/ssl/WeakCryptoOverride.cpp b/security/manager/ssl/WeakCryptoOverride.cpp new file mode 100644 index 0000000000..6b86e9f86e --- /dev/null +++ b/security/manager/ssl/WeakCryptoOverride.cpp @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "WeakCryptoOverride.h" + +#include "MainThreadUtils.h" +#include "SharedSSLState.h" +#include "nss.h" + +using namespace mozilla; +using namespace mozilla::psm; + +NS_IMPL_ISUPPORTS(WeakCryptoOverride, + nsIWeakCryptoOverride) + +WeakCryptoOverride::WeakCryptoOverride() +{ +} + +WeakCryptoOverride::~WeakCryptoOverride() +{ +} + +NS_IMETHODIMP +WeakCryptoOverride::AddWeakCryptoOverride(const nsACString& aHostName, + bool aPrivate, bool aTemporary) +{ + if (!NS_IsMainThread()) { + return NS_ERROR_NOT_SAME_THREAD; + } + + SharedSSLState* sharedState = aPrivate ? PrivateSSLState() + : PublicSSLState(); + if (!sharedState) { + return NS_ERROR_NOT_AVAILABLE; + } + const nsPromiseFlatCString& host = PromiseFlatCString(aHostName); + sharedState->IOLayerHelpers().addInsecureFallbackSite(host, aTemporary); + + return NS_OK; +} + +NS_IMETHODIMP +WeakCryptoOverride::RemoveWeakCryptoOverride(const nsACString& aHostName, + int32_t aPort, bool aPrivate) +{ + if (!NS_IsMainThread()) { + return NS_ERROR_NOT_SAME_THREAD; + } + + SharedSSLState* sharedState = aPrivate ? PrivateSSLState() + : PublicSSLState(); + if (!sharedState) { + return NS_ERROR_NOT_AVAILABLE; + } + const nsPromiseFlatCString& host = PromiseFlatCString(aHostName); + sharedState->IOLayerHelpers().removeInsecureFallbackSite(host, aPort); + + // Some servers will fail with SSL_ERROR_ILLEGAL_PARAMETER_ALERT + // unless the session cache is cleared. + SSL_ClearSessionCache(); + + return NS_OK; +} |