bool ArgumentCoder<ResourceError>::decode(ArgumentDecoder* decoder, ResourceError& resourceError) { String domain; if (!decoder->decode(domain)) return false; int errorCode; if (!decoder->decode(errorCode)) return false; String failingURL; if (!decoder->decode(failingURL)) return false; String localizedDescription; if (!decoder->decode(localizedDescription)) return false; #if USE(CFNETWORK) PlatformCertificateInfo certificate; if (!decoder->decode(certificate)) return false; const Vector<PCCERT_CONTEXT> certificateChain = certificate.certificateChain(); if (!certificateChain.isEmpty()) { ASSERT(certificateChain.size() == 1); resourceError = ResourceError(domain, errorCode, failingURL, localizedDescription, copyCertificateToData(certificateChain.first()).get()); return true; } #endif resourceError = ResourceError(domain, errorCode, failingURL, localizedDescription); return true; }
bool PlatformCertificateInfo::decode(CoreIPC::ArgumentDecoder* decoder, PlatformCertificateInfo& c) { uint64_t length; if (!decoder->decode(length)) return false; if (length == std::numeric_limits<uint64_t>::max()) { // This is the no certificates case. return true; } for (size_t i = 0; i < length; ++i) { Vector<uint8_t> bytes; if (!decoder->decodeBytes(bytes)) { c.clearCertificateChain(); return false; } PCCERT_CONTEXT certificateContext = ::CertCreateCertificateContext(PKCS_7_ASN_ENCODING | X509_ASN_ENCODING, bytes.data(), bytes.size()); if (!certificateContext) { c.clearCertificateChain(); return false; } c.m_certificateChain.append(certificateContext); } return true; }
bool ArgumentCoder<ResourceError>::decodePlatformData(ArgumentDecoder& decoder, ResourceError& resourceError) { PlatformCertificateInfo certificateInfo; if (!decoder.decode(certificateInfo)) return false; resourceError.setCertificate(certificateInfo.certificate()); resourceError.setTLSErrors(certificateInfo.tlsErrors()); return true; }
void WebResourceLoader::didReceiveResponseWithCertificateInfo(const ResourceResponse& response, const PlatformCertificateInfo& certificateInfo) { LOG(Network, "(WebProcess) WebResourceLoader::didReceiveResponseWithCertificateInfo for '%s'. Status %d.", m_coreLoader->url().string().utf8().data(), response.httpStatusCode()); ResourceResponse responseCopy(response); responseCopy.setCertificateChain(certificateInfo.certificateChain()); m_coreLoader->didReceiveResponse(responseCopy); }
void WebResourceLoader::didReceiveResponseWithCertificateInfo(const ResourceResponse& response, const PlatformCertificateInfo& certificateInfo, bool needsContinueDidReceiveResponseMessage) { LOG(Network, "(WebProcess) WebResourceLoader::didReceiveResponseWithCertificateInfo for '%s'. Status %d.", m_coreLoader->url().string().utf8().data(), response.httpStatusCode()); RefPtr<WebResourceLoader> protector(this); ResourceResponse responseCopy(response); responseCopy.setCertificateChain(certificateInfo.certificateChain()); m_coreLoader->didReceiveResponse(responseCopy); if (!m_coreLoader) return; if (needsContinueDidReceiveResponseMessage) send(Messages::NetworkResourceLoader::ContinueDidReceiveResponse()); }
void WebResourceLoader::didReceiveResponseWithCertificateInfo(const ResourceResponse& response, const PlatformCertificateInfo& certificateInfo, bool needsContinueDidReceiveResponseMessage) { LOG(Network, "(WebProcess) WebResourceLoader::didReceiveResponseWithCertificateInfo for '%s'. Status %d.", m_coreLoader->url().string().utf8().data(), response.httpStatusCode()); Ref<WebResourceLoader> protect(*this); ResourceResponse responseCopy(response); responseCopy.setCertificateChain(certificateInfo.certificateChain()); m_coreLoader->didReceiveResponse(responseCopy); // If m_coreLoader becomes null as a result of the didReceiveResponse callback, we can't use the send function(). if (!m_coreLoader) return; if (needsContinueDidReceiveResponseMessage) send(Messages::NetworkResourceLoader::ContinueDidReceiveResponse()); }
void WebProcess::allowSpecificHTTPSCertificateForHost(const PlatformCertificateInfo& certificateInfo, const String& host) { WebCore::ResourceHandle::setClientCertificate(host, certificateInfo.certificate()); }