Commit 9708f72a authored by Doug Turner's avatar Doug Turner Committed by Commit Bot

Network Service crash fix in network::mojom::SSLPrivateKeyProxy::Sign

This CL protects calling Sign() on a private key that is null. The key
can become null in two cases.  The first case is if |network_service_client_|
is null during OnCertificateRequested(). The second case is if
HandleSSLPrivateKeyError() is called.

In both cases, after this CL, if |ssl_private_key_| is null, we just call
the sign callback with net::ERR_SSL_CLIENT_AUTH_CERT_NO_PRIVATE_KEY.

Bug: 887539
Cq-Include-Trybots: luci.chromium.try:linux_mojo
Change-Id: I0e2563f00d73ff0659786e85a041567ceeaaea48
Reviewed-on: https://chromium-review.googlesource.com/1237396Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Doug Turner <dougt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593036}
parent 074bead6
...@@ -245,7 +245,7 @@ class SSLPrivateKeyInternal : public net::SSLPrivateKey { ...@@ -245,7 +245,7 @@ class SSLPrivateKeyInternal : public net::SSLPrivateKey {
base::span<const uint8_t> input, base::span<const uint8_t> input,
net::SSLPrivateKey::SignCallback callback) override { net::SSLPrivateKey::SignCallback callback) override {
std::vector<uint8_t> input_vector(input.begin(), input.end()); std::vector<uint8_t> input_vector(input.begin(), input.end());
if (ssl_private_key_.encountered_error()) { if (!ssl_private_key_ || ssl_private_key_.encountered_error()) {
base::ThreadTaskRunnerHandle::Get()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(std::move(callback), base::BindOnce(std::move(callback),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment