1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 "SocketProcessBackgroundParent.h"
#include "SocketProcessLogging.h"
#include "mozilla/ipc/Endpoint.h"
#include "mozilla/net/HttpConnectionMgrParent.h"
#include "mozilla/net/WebSocketConnectionParent.h"
#include "mozilla/psm/IPCClientCertsParent.h"
#include "mozilla/psm/VerifySSLServerCertParent.h"
#include "mozilla/psm/SelectTLSClientAuthCertParent.h"
#include "nsIHttpChannelInternal.h"
namespace mozilla::net {
SocketProcessBackgroundParent::SocketProcessBackgroundParent() {
LOG(("SocketProcessBackgroundParent ctor"));
}
SocketProcessBackgroundParent::~SocketProcessBackgroundParent() {
LOG(("SocketProcessBackgroundParent dtor"));
}
mozilla::ipc::IPCResult
SocketProcessBackgroundParent::RecvInitVerifySSLServerCert(
Endpoint<PVerifySSLServerCertParent>&& aEndpoint,
nsTArray<ByteArray>&& aPeerCertChain, const nsACString& aHostName,
const int32_t& aPort, const OriginAttributes& aOriginAttributes,
const Maybe<ByteArray>& aStapledOCSPResponse,
const Maybe<ByteArray>& aSctsFromTLSExtension,
const Maybe<DelegatedCredentialInfoArg>& aDcInfo,
const uint32_t& aProviderFlags, const uint32_t& aCertVerifierFlags) {
LOG(("SocketProcessBackgroundParent::RecvInitVerifySSLServerCert\n"));
if (!aEndpoint.IsValid()) {
return IPC_FAIL(this, "Invalid endpoint");
}
nsCOMPtr<nsISerialEventTarget> transportQueue;
if (NS_FAILED(NS_CreateBackgroundTaskQueue("VerifySSLServerCert",
getter_AddRefs(transportQueue)))) {
return IPC_FAIL(this, "NS_CreateBackgroundTaskQueue failed");
}
transportQueue->Dispatch(NS_NewRunnableFunction(
"InitVerifySSLServerCert",
[endpoint = std::move(aEndpoint),
peerCertChain = std::move(aPeerCertChain),
hostName = nsCString(aHostName), port(aPort),
originAttributes(aOriginAttributes),
stapledOCSPResponse = std::move(aStapledOCSPResponse),
sctsFromTLSExtension = std::move(aSctsFromTLSExtension),
dcInfo = std::move(aDcInfo), providerFlags(aProviderFlags),
certVerifierFlags(aCertVerifierFlags)]() mutable {
RefPtr<psm::VerifySSLServerCertParent> parent =
new psm::VerifySSLServerCertParent();
if (!endpoint.Bind(parent)) {
return;
}
parent->Dispatch(std::move(peerCertChain), hostName, port,
originAttributes, stapledOCSPResponse,
sctsFromTLSExtension, dcInfo, providerFlags,
certVerifierFlags);
}));
return IPC_OK();
}
mozilla::ipc::IPCResult
SocketProcessBackgroundParent::RecvInitSelectTLSClientAuthCert(
Endpoint<PSelectTLSClientAuthCertParent>&& aEndpoint,
const nsACString& aHostName, const OriginAttributes& aOriginAttributes,
const int32_t& aPort, const uint32_t& aProviderFlags,
const uint32_t& aProviderTlsFlags, const ByteArray& aServerCertBytes,
nsTArray<ByteArray>&& aCANames, const uint64_t& aBrowserId) {
LOG(("SocketProcessBackgroundParent::RecvInitSelectTLSClientAuthCert\n"));
if (!aEndpoint.IsValid()) {
return IPC_FAIL(this, "Invalid endpoint");
}
nsCOMPtr<nsISerialEventTarget> transportQueue;
if (NS_FAILED(NS_CreateBackgroundTaskQueue("SelectTLSClientAuthCert",
getter_AddRefs(transportQueue)))) {
return IPC_FAIL(this, "NS_CreateBackgroundTaskQueue failed");
}
transportQueue->Dispatch(NS_NewRunnableFunction(
"InitSelectTLSClientAuthCert",
[endpoint = std::move(aEndpoint), hostName = nsCString(aHostName),
originAttributes(aOriginAttributes), port(aPort),
providerFlags(aProviderFlags), providerTlsFlags(aProviderTlsFlags),
serverCertBytes(aServerCertBytes), CANAMEs(std::move(aCANames)),
browserId(aBrowserId)]() mutable {
RefPtr<psm::SelectTLSClientAuthCertParent> parent =
new psm::SelectTLSClientAuthCertParent();
if (!endpoint.Bind(parent)) {
return;
}
parent->Dispatch(hostName, originAttributes, port, providerFlags,
providerTlsFlags, serverCertBytes, std::move(CANAMEs),
browserId);
}));
return IPC_OK();
}
mozilla::ipc::IPCResult SocketProcessBackgroundParent::RecvInitIPCClientCerts(
Endpoint<PIPCClientCertsParent>&& aEndpoint) {
LOG(("SocketProcessBackgroundParent::RecvInitIPCClientCerts\n"));
if (!aEndpoint.IsValid()) {
return IPC_FAIL(this, "Invalid endpoint");
}
nsCOMPtr<nsISerialEventTarget> transportQueue;
if (NS_FAILED(NS_CreateBackgroundTaskQueue("IPCClientCerts",
getter_AddRefs(transportQueue)))) {
return IPC_FAIL(this, "NS_CreateBackgroundTaskQueue failed");
}
transportQueue->Dispatch(NS_NewRunnableFunction(
"InitIPCClientCerts", [endpoint = std::move(aEndpoint)]() mutable {
RefPtr<psm::IPCClientCertsParent> parent =
new psm::IPCClientCertsParent();
endpoint.Bind(parent);
}));
return IPC_OK();
}
mozilla::ipc::IPCResult
SocketProcessBackgroundParent::RecvInitWebSocketConnection(
Endpoint<PWebSocketConnectionParent>&& aEndpoint,
const uint32_t& aListenerId) {
LOG(("SocketProcessBackgroundParent::RecvInitWebSocketConnection\n"));
if (!aEndpoint.IsValid()) {
return IPC_FAIL(this, "Invalid endpoint");
}
nsCOMPtr<nsISerialEventTarget> transportQueue;
if (NS_FAILED(NS_CreateBackgroundTaskQueue("WebSocketConnection",
getter_AddRefs(transportQueue)))) {
return IPC_FAIL(this, "NS_CreateBackgroundTaskQueue failed");
}
transportQueue->Dispatch(NS_NewRunnableFunction(
"InitWebSocketConnection",
[endpoint = std::move(aEndpoint), aListenerId]() mutable {
Maybe<nsCOMPtr<nsIHttpUpgradeListener>> listener =
net::HttpConnectionMgrParent::GetAndRemoveHttpUpgradeListener(
aListenerId);
if (!listener) {
return;
}
RefPtr<WebSocketConnectionParent> actor =
new WebSocketConnectionParent(*listener);
endpoint.Bind(actor);
}));
return IPC_OK();
}
void SocketProcessBackgroundParent::ActorDestroy(ActorDestroyReason aReason) {
LOG(("SocketProcessBackgroundParent::ActorDestroy"));
}
} // namespace mozilla::net
|