• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   // Used with AlloyContentBrowserClient::SelectClientCertificate only.
21   explicit CefX509CertificateImpl(
22       std::unique_ptr<net::ClientCertIdentity> identity);
23 
24   // CefX509Certificate methods.
25   CefRefPtr<CefX509CertPrincipal> GetSubject() override;
26   CefRefPtr<CefX509CertPrincipal> GetIssuer() override;
27   CefRefPtr<CefBinaryValue> GetSerialNumber() override;
28   CefTime GetValidStart() override;
29   CefTime GetValidExpiry() override;
30   CefRefPtr<CefBinaryValue> GetDEREncoded() override;
31   CefRefPtr<CefBinaryValue> GetPEMEncoded() override;
32   size_t GetIssuerChainSize() override;
33   void GetDEREncodedIssuerChain(IssuerChainBinaryList& chain) override;
34   void GetPEMEncodedIssuerChain(IssuerChainBinaryList& chain) override;
35 
GetInternalCertObject()36   scoped_refptr<net::X509Certificate> GetInternalCertObject() { return cert_; }
37   void AcquirePrivateKey(
38       base::OnceCallback<void(scoped_refptr<net::SSLPrivateKey>)>
39           private_key_callback);
40 
41  private:
42   void GetEncodedIssuerChain(IssuerChainBinaryList& chain, bool der);
43 
44   std::unique_ptr<net::ClientCertIdentity> identity_;
45   scoped_refptr<net::X509Certificate> cert_;
46   IssuerChainBinaryList pem_encoded_issuer_chain_;
47   IssuerChainBinaryList der_encoded_issuer_chain_;
48 
49   IMPLEMENT_REFCOUNTING(CefX509CertificateImpl);
50   DISALLOW_COPY_AND_ASSIGN(CefX509CertificateImpl);
51 };
52 
53 #endif  // CEF_LIBCEF_BROWSER_X509_CERTIFICATE_IMPL_H_
54