mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add API for SSL status and certificate retrieval (issue #1924)
This commit is contained in:
@@ -893,6 +893,22 @@ void CefBrowserHostImpl::GetNavigationEntries(
|
||||
}
|
||||
}
|
||||
|
||||
CefRefPtr<CefNavigationEntry> CefBrowserHostImpl::GetVisibleNavigationEntry() {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
NOTREACHED() << "called on invalid thread";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
content::NavigationEntry* entry = nullptr;
|
||||
if (web_contents())
|
||||
entry = web_contents()->GetController().GetVisibleEntry();
|
||||
|
||||
if (!entry)
|
||||
return nullptr;
|
||||
|
||||
return new CefNavigationEntryImpl(entry);
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::SetMouseCursorChangeDisabled(bool disabled) {
|
||||
base::AutoLock lock_scope(state_lock_);
|
||||
mouse_cursor_change_disabled_ = disabled;
|
||||
|
@@ -218,6 +218,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
void DragTargetDrop(const CefMouseEvent& event) override;
|
||||
void DragSourceSystemDragEnded() override;
|
||||
void DragSourceEndedAt(int x, int y, DragOperationsMask op) override;
|
||||
CefRefPtr<CefNavigationEntry> GetVisibleNavigationEntry() override;
|
||||
|
||||
// CefBrowser methods.
|
||||
CefRefPtr<CefBrowserHost> GetHost() override;
|
||||
|
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "libcef/browser/navigation_entry_impl.h"
|
||||
|
||||
#include "libcef/browser/ssl_status_impl.h"
|
||||
#include "libcef/common/time_util.h"
|
||||
|
||||
#include "content/public/browser/navigation_entry.h"
|
||||
@@ -62,3 +63,9 @@ int CefNavigationEntryImpl::GetHttpStatusCode() {
|
||||
CEF_VALUE_VERIFY_RETURN(false, 0);
|
||||
return const_value().GetHttpStatusCode();
|
||||
}
|
||||
|
||||
CefRefPtr<CefSSLStatus> CefNavigationEntryImpl::GetSSLStatus() {
|
||||
CEF_VALUE_VERIFY_RETURN(false, nullptr);
|
||||
return new CefSSLStatusImpl(const_value().GetSSL());
|
||||
}
|
||||
|
||||
|
@@ -29,6 +29,7 @@ class CefNavigationEntryImpl
|
||||
bool HasPostData() override;
|
||||
CefTime GetCompletionTime() override;
|
||||
int GetHttpStatusCode() override;
|
||||
CefRefPtr<CefSSLStatus> GetSSLStatus() override;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(CefNavigationEntryImpl);
|
||||
|
@@ -3,121 +3,30 @@
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/ssl_info_impl.h"
|
||||
#include "libcef/browser/ssl_cert_principal_impl.h"
|
||||
#include "libcef/common/time_util.h"
|
||||
#include "libcef/browser/x509_certificate_impl.h"
|
||||
|
||||
#include "net/cert/cert_status_flags.h"
|
||||
#include "net/cert/x509_certificate.h"
|
||||
|
||||
namespace {
|
||||
|
||||
void EncodeCertificate(
|
||||
const net::X509Certificate::OSCertHandle& os_handle,
|
||||
CefRefPtr<CefBinaryValue>& der_encoded,
|
||||
CefRefPtr<CefBinaryValue>& pem_encoded) {
|
||||
std::string encoded;
|
||||
if (net::X509Certificate::GetDEREncoded(os_handle, &encoded)) {
|
||||
der_encoded = CefBinaryValue::Create(encoded.c_str(),
|
||||
encoded.size());
|
||||
}
|
||||
encoded.clear();
|
||||
if (net::X509Certificate::GetPEMEncoded(os_handle, &encoded)) {
|
||||
pem_encoded = CefBinaryValue::Create(encoded.c_str(),
|
||||
encoded.size());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
CefSSLInfoImpl::CefSSLInfoImpl(const net::SSLInfo& value)
|
||||
: cert_status_(CERT_STATUS_NONE) {
|
||||
cert_status_ = static_cast<cef_cert_status_t>(value.cert_status);
|
||||
if (value.cert.get()) {
|
||||
cert_status_ = static_cast<cef_cert_status_t>(value.cert_status);
|
||||
|
||||
subject_ = new CefSSLCertPrincipalImpl(value.cert->subject());
|
||||
issuer_ = new CefSSLCertPrincipalImpl(value.cert->issuer());
|
||||
|
||||
const std::string& serial_number = value.cert->serial_number();
|
||||
serial_number_ = CefBinaryValue::Create(serial_number.c_str(),
|
||||
serial_number.size());
|
||||
|
||||
const base::Time& valid_start = value.cert->valid_start();
|
||||
if (!valid_start.is_null())
|
||||
cef_time_from_basetime(valid_start, valid_start_);
|
||||
|
||||
const base::Time& valid_expiry = value.cert->valid_expiry();
|
||||
if (!valid_expiry.is_null())
|
||||
cef_time_from_basetime(valid_expiry, valid_expiry_);
|
||||
|
||||
net::X509Certificate::OSCertHandle os_handle = value.cert->os_cert_handle();
|
||||
if (os_handle)
|
||||
EncodeCertificate(os_handle, der_encoded_, pem_encoded_);
|
||||
|
||||
const net::X509Certificate::OSCertHandles& issuer_chain =
|
||||
value.cert->GetIntermediateCertificates();
|
||||
for (net::X509Certificate::OSCertHandles::const_iterator it =
|
||||
issuer_chain.begin(); it != issuer_chain.end(); it++) {
|
||||
CefRefPtr<CefBinaryValue> der_encoded, pem_encoded;
|
||||
EncodeCertificate(*it, der_encoded, pem_encoded);
|
||||
|
||||
// Add each to the chain, even if one conversion unexpectedly failed.
|
||||
// GetIssuerChainSize depends on these being the same length.
|
||||
der_encoded_issuer_chain_.push_back(der_encoded);
|
||||
pem_encoded_issuer_chain_.push_back(pem_encoded);
|
||||
}
|
||||
cert_ = new CefX509CertificateImpl(*value.cert);
|
||||
}
|
||||
}
|
||||
|
||||
cef_cert_status_t CefSSLInfoImpl::GetCertStatus() {
|
||||
return cert_status_;
|
||||
return cert_status_;
|
||||
}
|
||||
|
||||
bool CefSSLInfoImpl::IsCertStatusError() {
|
||||
return net::IsCertStatusError(cert_status_);
|
||||
CefRefPtr<CefX509Certificate> CefSSLInfoImpl::GetX509Certificate() {
|
||||
return cert_;
|
||||
}
|
||||
|
||||
bool CefSSLInfoImpl::IsCertStatusMinorError() {
|
||||
return net::IsCertStatusMinorError(cert_status_);
|
||||
bool CefIsCertStatusError(cef_cert_status_t status) {
|
||||
return net::IsCertStatusError(status);
|
||||
}
|
||||
|
||||
CefRefPtr<CefSSLCertPrincipal> CefSSLInfoImpl::GetSubject() {
|
||||
return subject_;
|
||||
}
|
||||
|
||||
CefRefPtr<CefSSLCertPrincipal> CefSSLInfoImpl::GetIssuer() {
|
||||
return issuer_;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBinaryValue> CefSSLInfoImpl::GetSerialNumber() {
|
||||
return serial_number_;
|
||||
}
|
||||
|
||||
CefTime CefSSLInfoImpl::GetValidStart() {
|
||||
return valid_start_;
|
||||
}
|
||||
|
||||
CefTime CefSSLInfoImpl::GetValidExpiry() {
|
||||
return valid_expiry_;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBinaryValue> CefSSLInfoImpl::GetDEREncoded() {
|
||||
return der_encoded_;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBinaryValue> CefSSLInfoImpl::GetPEMEncoded() {
|
||||
return pem_encoded_;
|
||||
}
|
||||
|
||||
size_t CefSSLInfoImpl::GetIssuerChainSize() {
|
||||
return der_encoded_issuer_chain_.size();
|
||||
}
|
||||
|
||||
void CefSSLInfoImpl::GetDEREncodedIssuerChain(
|
||||
CefSSLInfo::IssuerChainBinaryList& chain) {
|
||||
chain = der_encoded_issuer_chain_;
|
||||
}
|
||||
|
||||
void CefSSLInfoImpl::GetPEMEncodedIssuerChain(
|
||||
CefSSLInfo::IssuerChainBinaryList& chain) {
|
||||
chain = pem_encoded_issuer_chain_;
|
||||
bool CefIsCertStatusMinorError(cef_cert_status_t status) {
|
||||
return net::IsCertStatusMinorError(status);
|
||||
}
|
||||
|
@@ -17,30 +17,11 @@ class CefSSLInfoImpl : public CefSSLInfo {
|
||||
|
||||
// CefSSLInfo methods.
|
||||
cef_cert_status_t GetCertStatus() override;
|
||||
bool IsCertStatusError() override;
|
||||
bool IsCertStatusMinorError() override;
|
||||
CefRefPtr<CefSSLCertPrincipal> GetSubject() override;
|
||||
CefRefPtr<CefSSLCertPrincipal> GetIssuer() override;
|
||||
CefRefPtr<CefBinaryValue> GetSerialNumber() override;
|
||||
CefTime GetValidStart() override;
|
||||
CefTime GetValidExpiry() override;
|
||||
CefRefPtr<CefBinaryValue> GetDEREncoded() override;
|
||||
CefRefPtr<CefBinaryValue> GetPEMEncoded() override;
|
||||
size_t GetIssuerChainSize() override;
|
||||
void GetDEREncodedIssuerChain(IssuerChainBinaryList& chain) override;
|
||||
void GetPEMEncodedIssuerChain(IssuerChainBinaryList& chain) override;
|
||||
CefRefPtr<CefX509Certificate> GetX509Certificate() override;
|
||||
|
||||
private:
|
||||
cef_cert_status_t cert_status_;
|
||||
CefRefPtr<CefSSLCertPrincipal> subject_;
|
||||
CefRefPtr<CefSSLCertPrincipal> issuer_;
|
||||
CefRefPtr<CefBinaryValue> serial_number_;
|
||||
CefTime valid_start_;
|
||||
CefTime valid_expiry_;
|
||||
CefRefPtr<CefBinaryValue> der_encoded_;
|
||||
CefRefPtr<CefBinaryValue> pem_encoded_;
|
||||
IssuerChainBinaryList der_encoded_issuer_chain_;
|
||||
IssuerChainBinaryList pem_encoded_issuer_chain_;
|
||||
CefRefPtr<CefX509Certificate> cert_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefSSLInfoImpl);
|
||||
DISALLOW_COPY_AND_ASSIGN(CefSSLInfoImpl);
|
||||
|
45
libcef/browser/ssl_status_impl.cc
Normal file
45
libcef/browser/ssl_status_impl.cc
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright (c) 2016 The Chromium Embedded Framework 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 "libcef/browser/ssl_status_impl.h"
|
||||
|
||||
#include "libcef/browser/x509_certificate_impl.h"
|
||||
|
||||
#include "content/public/browser/cert_store.h"
|
||||
#include "net/ssl/ssl_connection_status_flags.h"
|
||||
|
||||
CefSSLStatusImpl::CefSSLStatusImpl(const content::SSLStatus& value) {
|
||||
cert_status_ = static_cast<cef_cert_status_t>(value.cert_status);
|
||||
content_status_ = static_cast<cef_ssl_content_status_t>(value.content_status);
|
||||
ssl_version_ = static_cast<cef_ssl_version_t>(
|
||||
net::SSLConnectionStatusToVersion(value.connection_status));
|
||||
cert_id_ = value.cert_id;
|
||||
}
|
||||
|
||||
bool CefSSLStatusImpl::IsSecureConnection() {
|
||||
// Secure connection if there was a certificate ID in SSLStatus.
|
||||
return (cert_id_ != 0);
|
||||
}
|
||||
|
||||
cef_cert_status_t CefSSLStatusImpl::GetCertStatus() {
|
||||
return cert_status_;
|
||||
}
|
||||
|
||||
cef_ssl_version_t CefSSLStatusImpl::GetSSLVersion() {
|
||||
return ssl_version_;
|
||||
}
|
||||
|
||||
cef_ssl_content_status_t CefSSLStatusImpl::GetContentStatus() {
|
||||
return content_status_;
|
||||
}
|
||||
|
||||
CefRefPtr<CefX509Certificate> CefSSLStatusImpl::GetX509Certificate() {
|
||||
if (cert_id_) {
|
||||
scoped_refptr<net::X509Certificate> cert;
|
||||
content::CertStore::GetInstance()->RetrieveCert(cert_id_, &cert);
|
||||
if (cert.get())
|
||||
return new CefX509CertificateImpl(*cert);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
35
libcef/browser/ssl_status_impl.h
Normal file
35
libcef/browser/ssl_status_impl.h
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_SSL_STATUS_IMPL_H_
|
||||
#define CEF_LIBCEF_BROWSER_SSL_STATUS_IMPL_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_ssl_status.h"
|
||||
|
||||
#include "content/public/common/ssl_status.h"
|
||||
|
||||
// CefSSLStatus implementation
|
||||
class CefSSLStatusImpl : public CefSSLStatus {
|
||||
public:
|
||||
explicit CefSSLStatusImpl(const content::SSLStatus& value);
|
||||
|
||||
// CefSSLStatus methods.
|
||||
bool IsSecureConnection() override;
|
||||
cef_cert_status_t GetCertStatus() override;
|
||||
cef_ssl_version_t GetSSLVersion() override;
|
||||
cef_ssl_content_status_t GetContentStatus() override;
|
||||
CefRefPtr<CefX509Certificate> GetX509Certificate() override;
|
||||
|
||||
private:
|
||||
cef_cert_status_t cert_status_;
|
||||
cef_ssl_version_t ssl_version_;
|
||||
cef_ssl_content_status_t content_status_;
|
||||
int cert_id_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefSSLStatusImpl);
|
||||
DISALLOW_COPY_AND_ASSIGN(CefSSLStatusImpl);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_SSL_STATUS_IMPL_H_
|
@@ -1,8 +1,8 @@
|
||||
// Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights
|
||||
// Copyright (c) 2016 The Chromium Embedded Framework 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 "libcef/browser/ssl_cert_principal_impl.h"
|
||||
#include "libcef/browser/x509_cert_principal_impl.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -20,47 +20,47 @@ void TransferVector(const std::vector<std::string>& source,
|
||||
|
||||
} // namespace
|
||||
|
||||
CefSSLCertPrincipalImpl::CefSSLCertPrincipalImpl(
|
||||
CefX509CertPrincipalImpl::CefX509CertPrincipalImpl(
|
||||
const net::CertPrincipal& value)
|
||||
: value_(value) {
|
||||
}
|
||||
|
||||
CefString CefSSLCertPrincipalImpl::GetDisplayName() {
|
||||
CefString CefX509CertPrincipalImpl::GetDisplayName() {
|
||||
return value_.GetDisplayName();
|
||||
}
|
||||
|
||||
CefString CefSSLCertPrincipalImpl::GetCommonName() {
|
||||
CefString CefX509CertPrincipalImpl::GetCommonName() {
|
||||
return value_.common_name;
|
||||
}
|
||||
|
||||
CefString CefSSLCertPrincipalImpl::GetLocalityName() {
|
||||
CefString CefX509CertPrincipalImpl::GetLocalityName() {
|
||||
return value_.locality_name;
|
||||
}
|
||||
|
||||
CefString CefSSLCertPrincipalImpl::GetStateOrProvinceName() {
|
||||
CefString CefX509CertPrincipalImpl::GetStateOrProvinceName() {
|
||||
return value_.state_or_province_name;
|
||||
}
|
||||
|
||||
CefString CefSSLCertPrincipalImpl::GetCountryName() {
|
||||
CefString CefX509CertPrincipalImpl::GetCountryName() {
|
||||
return value_.country_name;
|
||||
}
|
||||
|
||||
void CefSSLCertPrincipalImpl::GetStreetAddresses(
|
||||
void CefX509CertPrincipalImpl::GetStreetAddresses(
|
||||
std::vector<CefString>& addresses) {
|
||||
TransferVector(value_.street_addresses, addresses);
|
||||
}
|
||||
|
||||
void CefSSLCertPrincipalImpl::GetOrganizationNames(
|
||||
void CefX509CertPrincipalImpl::GetOrganizationNames(
|
||||
std::vector<CefString>& names) {
|
||||
TransferVector(value_.organization_names, names);
|
||||
}
|
||||
|
||||
void CefSSLCertPrincipalImpl::GetOrganizationUnitNames(
|
||||
void CefX509CertPrincipalImpl::GetOrganizationUnitNames(
|
||||
std::vector<CefString>& names) {
|
||||
TransferVector(value_.organization_unit_names, names);
|
||||
}
|
||||
|
||||
void CefSSLCertPrincipalImpl::GetDomainComponents(
|
||||
void CefX509CertPrincipalImpl::GetDomainComponents(
|
||||
std::vector<CefString>& components) {
|
||||
TransferVector(value_.domain_components, components);
|
||||
}
|
@@ -1,21 +1,21 @@
|
||||
// Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights
|
||||
// Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_SSL_CERT_PRINCIPAL_IMPL_H_
|
||||
#define CEF_LIBCEF_BROWSER_SSL_CERT_PRINCIPAL_IMPL_H_
|
||||
#ifndef CEF_LIBCEF_BROWSER_X509_CERT_PRINCIPAL_IMPL_H_
|
||||
#define CEF_LIBCEF_BROWSER_X509_CERT_PRINCIPAL_IMPL_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_ssl_info.h"
|
||||
#include "include/cef_x509_certificate.h"
|
||||
|
||||
#include "net/cert/x509_cert_types.h"
|
||||
|
||||
// CefSSLCertPrincipal implementation
|
||||
class CefSSLCertPrincipalImpl : public CefSSLCertPrincipal {
|
||||
// CefX509CertPrincipal implementation
|
||||
class CefX509CertPrincipalImpl : public CefX509CertPrincipal {
|
||||
public:
|
||||
explicit CefSSLCertPrincipalImpl(const net::CertPrincipal& value);
|
||||
explicit CefX509CertPrincipalImpl(const net::CertPrincipal& value);
|
||||
|
||||
// CefSSLCertPrincipal methods.
|
||||
// CefX509CertPrincipal methods.
|
||||
CefString GetDisplayName() override;
|
||||
CefString GetCommonName() override;
|
||||
CefString GetLocalityName() override;
|
||||
@@ -29,8 +29,8 @@ class CefSSLCertPrincipalImpl : public CefSSLCertPrincipal {
|
||||
private:
|
||||
net::CertPrincipal value_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefSSLCertPrincipalImpl);
|
||||
DISALLOW_COPY_AND_ASSIGN(CefSSLCertPrincipalImpl);
|
||||
IMPLEMENT_REFCOUNTING(CefX509CertPrincipalImpl);
|
||||
DISALLOW_COPY_AND_ASSIGN(CefX509CertPrincipalImpl);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_SSL_CERT_PRINCIPAL_IMPL_H_
|
||||
#endif // CEF_LIBCEF_BROWSER_X509_CERT_PRINCIPAL_IMPL_H_
|
104
libcef/browser/x509_certificate_impl.cc
Normal file
104
libcef/browser/x509_certificate_impl.cc
Normal file
@@ -0,0 +1,104 @@
|
||||
// Copyright (c) 2016 The Chromium Embedded Framework 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 "libcef/browser/x509_certificate_impl.h"
|
||||
#include "libcef/browser/x509_cert_principal_impl.h"
|
||||
#include "libcef/common/time_util.h"
|
||||
|
||||
namespace {
|
||||
|
||||
void EncodeCertificate(
|
||||
const net::X509Certificate::OSCertHandle& os_handle,
|
||||
CefRefPtr<CefBinaryValue>& der_encoded,
|
||||
CefRefPtr<CefBinaryValue>& pem_encoded) {
|
||||
std::string encoded;
|
||||
if (net::X509Certificate::GetDEREncoded(os_handle, &encoded)) {
|
||||
der_encoded = CefBinaryValue::Create(encoded.c_str(),
|
||||
encoded.size());
|
||||
}
|
||||
encoded.clear();
|
||||
if (net::X509Certificate::GetPEMEncoded(os_handle, &encoded)) {
|
||||
pem_encoded = CefBinaryValue::Create(encoded.c_str(),
|
||||
encoded.size());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
CefX509CertificateImpl::CefX509CertificateImpl(
|
||||
const net::X509Certificate& value) {
|
||||
subject_ = new CefX509CertPrincipalImpl(value.subject());
|
||||
issuer_ = new CefX509CertPrincipalImpl(value.issuer());
|
||||
|
||||
const std::string& serial_number = value.serial_number();
|
||||
serial_number_ = CefBinaryValue::Create(serial_number.c_str(),
|
||||
serial_number.size());
|
||||
|
||||
const base::Time& valid_start = value.valid_start();
|
||||
if (!valid_start.is_null())
|
||||
cef_time_from_basetime(valid_start, valid_start_);
|
||||
|
||||
const base::Time& valid_expiry = value.valid_expiry();
|
||||
if (!valid_expiry.is_null())
|
||||
cef_time_from_basetime(valid_expiry, valid_expiry_);
|
||||
|
||||
net::X509Certificate::OSCertHandle os_handle = value.os_cert_handle();
|
||||
if (os_handle)
|
||||
EncodeCertificate(os_handle, der_encoded_, pem_encoded_);
|
||||
|
||||
const net::X509Certificate::OSCertHandles& issuer_chain =
|
||||
value.GetIntermediateCertificates();
|
||||
for (net::X509Certificate::OSCertHandles::const_iterator it =
|
||||
issuer_chain.begin(); it != issuer_chain.end(); it++) {
|
||||
CefRefPtr<CefBinaryValue> der_encoded, pem_encoded;
|
||||
EncodeCertificate(*it, der_encoded, pem_encoded);
|
||||
|
||||
// Add each to the chain, even if one conversion unexpectedly failed.
|
||||
// GetIssuerChainSize depends on these being the same length.
|
||||
der_encoded_issuer_chain_.push_back(der_encoded);
|
||||
pem_encoded_issuer_chain_.push_back(pem_encoded);
|
||||
}
|
||||
}
|
||||
|
||||
CefRefPtr<CefX509CertPrincipal> CefX509CertificateImpl::GetSubject() {
|
||||
return subject_;
|
||||
}
|
||||
|
||||
CefRefPtr<CefX509CertPrincipal> CefX509CertificateImpl::GetIssuer() {
|
||||
return issuer_;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBinaryValue> CefX509CertificateImpl::GetSerialNumber() {
|
||||
return serial_number_;
|
||||
}
|
||||
|
||||
CefTime CefX509CertificateImpl::GetValidStart() {
|
||||
return valid_start_;
|
||||
}
|
||||
|
||||
CefTime CefX509CertificateImpl::GetValidExpiry() {
|
||||
return valid_expiry_;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBinaryValue> CefX509CertificateImpl::GetDEREncoded() {
|
||||
return der_encoded_;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBinaryValue> CefX509CertificateImpl::GetPEMEncoded() {
|
||||
return pem_encoded_;
|
||||
}
|
||||
|
||||
size_t CefX509CertificateImpl::GetIssuerChainSize() {
|
||||
return der_encoded_issuer_chain_.size();
|
||||
}
|
||||
|
||||
void CefX509CertificateImpl::GetDEREncodedIssuerChain(
|
||||
CefX509Certificate::IssuerChainBinaryList& chain) {
|
||||
chain = der_encoded_issuer_chain_;
|
||||
}
|
||||
|
||||
void CefX509CertificateImpl::GetPEMEncodedIssuerChain(
|
||||
CefX509Certificate::IssuerChainBinaryList& chain) {
|
||||
chain = pem_encoded_issuer_chain_;
|
||||
}
|
45
libcef/browser/x509_certificate_impl.h
Normal file
45
libcef/browser/x509_certificate_impl.h
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_X509_CERTIFICATE_IMPL_H_
|
||||
#define CEF_LIBCEF_BROWSER_X509_CERTIFICATE_IMPL_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_x509_certificate.h"
|
||||
|
||||
#include "net/cert/x509_certificate.h"
|
||||
|
||||
// CefX509Certificate implementation
|
||||
class CefX509CertificateImpl : public CefX509Certificate {
|
||||
public:
|
||||
explicit CefX509CertificateImpl(const net::X509Certificate& value);
|
||||
|
||||
// CefX509Certificate methods.
|
||||
CefRefPtr<CefX509CertPrincipal> GetSubject() override;
|
||||
CefRefPtr<CefX509CertPrincipal> GetIssuer() override;
|
||||
CefRefPtr<CefBinaryValue> GetSerialNumber() override;
|
||||
CefTime GetValidStart() override;
|
||||
CefTime GetValidExpiry() override;
|
||||
CefRefPtr<CefBinaryValue> GetDEREncoded() override;
|
||||
CefRefPtr<CefBinaryValue> GetPEMEncoded() override;
|
||||
size_t GetIssuerChainSize() override;
|
||||
void GetDEREncodedIssuerChain(IssuerChainBinaryList& chain) override;
|
||||
void GetPEMEncodedIssuerChain(IssuerChainBinaryList& chain) override;
|
||||
|
||||
private:
|
||||
CefRefPtr<CefX509CertPrincipal> subject_;
|
||||
CefRefPtr<CefX509CertPrincipal> issuer_;
|
||||
CefRefPtr<CefBinaryValue> serial_number_;
|
||||
CefTime valid_start_;
|
||||
CefTime valid_expiry_;
|
||||
CefRefPtr<CefBinaryValue> der_encoded_;
|
||||
CefRefPtr<CefBinaryValue> pem_encoded_;
|
||||
IssuerChainBinaryList der_encoded_issuer_chain_;
|
||||
IssuerChainBinaryList pem_encoded_issuer_chain_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefX509CertificateImpl);
|
||||
DISALLOW_COPY_AND_ASSIGN(CefX509CertificateImpl);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_X509_CERTIFICATE_IMPL_H_
|
Reference in New Issue
Block a user