1 // Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights 2 // reserved. Use of this source code is governed by a BSD-style license that 3 // can be found in the LICENSE file. 4 5 #ifndef CEF_LIBCEF_BROWSER_X509_CERTIFICATE_IMPL_H_ 6 #define CEF_LIBCEF_BROWSER_X509_CERTIFICATE_IMPL_H_ 7 #pragma once 8 9 #include "include/cef_x509_certificate.h" 10 11 #include <memory> 12 13 #include "net/ssl/client_cert_identity.h" 14 15 // CefX509Certificate implementation 16 class CefX509CertificateImpl : public CefX509Certificate { 17 public: 18 explicit CefX509CertificateImpl(scoped_refptr<net::X509Certificate> cert); 19 20 CefX509CertificateImpl(const CefX509CertificateImpl&) = delete; 21 CefX509CertificateImpl& operator=(const CefX509CertificateImpl&) = delete; 22 23 // Used with AlloyContentBrowserClient::SelectClientCertificate only. 24 explicit CefX509CertificateImpl( 25 std::unique_ptr<net::ClientCertIdentity> identity); 26 27 // CefX509Certificate methods. 28 CefRefPtr<CefX509CertPrincipal> GetSubject() override; 29 CefRefPtr<CefX509CertPrincipal> GetIssuer() override; 30 CefRefPtr<CefBinaryValue> GetSerialNumber() override; 31 CefTime GetValidStart() override; 32 CefTime GetValidExpiry() override; 33 CefRefPtr<CefBinaryValue> GetDEREncoded() override; 34 CefRefPtr<CefBinaryValue> GetPEMEncoded() override; 35 size_t GetIssuerChainSize() override; 36 void GetDEREncodedIssuerChain(IssuerChainBinaryList& chain) override; 37 void GetPEMEncodedIssuerChain(IssuerChainBinaryList& chain) override; 38 GetInternalCertObject()39 scoped_refptr<net::X509Certificate> GetInternalCertObject() { return cert_; } 40 void AcquirePrivateKey( 41 base::OnceCallback<void(scoped_refptr<net::SSLPrivateKey>)> 42 private_key_callback); 43 44 private: 45 void GetEncodedIssuerChain(IssuerChainBinaryList& chain, bool der); 46 47 std::unique_ptr<net::ClientCertIdentity> identity_; 48 scoped_refptr<net::X509Certificate> cert_; 49 IssuerChainBinaryList pem_encoded_issuer_chain_; 50 IssuerChainBinaryList der_encoded_issuer_chain_; 51 52 IMPLEMENT_REFCOUNTING(CefX509CertificateImpl); 53 }; 54 55 #endif // CEF_LIBCEF_BROWSER_X509_CERTIFICATE_IMPL_H_ 56