• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 //    * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 //    * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 //    * Neither the name of Google Inc. nor the name Chromium Embedded
14 // Framework nor the names of its contributors may be used to endorse
15 // or promote products derived from this software without specific prior
16 // written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // ---------------------------------------------------------------------------
31 //
32 // The contents of this file must follow a specific format in order to
33 // support the CEF translator tool. See the translator.README.txt file in the
34 // tools directory for more information.
35 //
36 
37 #ifndef CEF_INCLUDE_CEF_X509_CERTIFICATE_H_
38 #define CEF_INCLUDE_CEF_X509_CERTIFICATE_H_
39 #pragma once
40 
41 #include <vector>
42 
43 #include "include/cef_base.h"
44 #include "include/cef_values.h"
45 
46 ///
47 // Class representing the issuer or subject field of an X.509 certificate.
48 ///
49 /*--cef(source=library)--*/
50 class CefX509CertPrincipal : public virtual CefBaseRefCounted {
51  public:
52   ///
53   // Returns a name that can be used to represent the issuer. It tries in this
54   // order: Common Name (CN), Organization Name (O) and Organizational Unit
55   // Name (OU) and returns the first non-empty one found.
56   ///
57   /*--cef()--*/
58   virtual CefString GetDisplayName() = 0;
59 
60   ///
61   // Returns the common name.
62   ///
63   /*--cef()--*/
64   virtual CefString GetCommonName() = 0;
65 
66   ///
67   // Returns the locality name.
68   ///
69   /*--cef()--*/
70   virtual CefString GetLocalityName() = 0;
71 
72   ///
73   // Returns the state or province name.
74   ///
75   /*--cef()--*/
76   virtual CefString GetStateOrProvinceName() = 0;
77 
78   ///
79   // Returns the country name.
80   ///
81   /*--cef()--*/
82   virtual CefString GetCountryName() = 0;
83 
84   ///
85   // Retrieve the list of street addresses.
86   ///
87   /*--cef()--*/
88   virtual void GetStreetAddresses(std::vector<CefString>& addresses) = 0;
89 
90   ///
91   // Retrieve the list of organization names.
92   ///
93   /*--cef()--*/
94   virtual void GetOrganizationNames(std::vector<CefString>& names) = 0;
95 
96   ///
97   // Retrieve the list of organization unit names.
98   ///
99   /*--cef()--*/
100   virtual void GetOrganizationUnitNames(std::vector<CefString>& names) = 0;
101 
102   ///
103   // Retrieve the list of domain components.
104   ///
105   /*--cef()--*/
106   virtual void GetDomainComponents(std::vector<CefString>& components) = 0;
107 };
108 
109 ///
110 // Class representing a X.509 certificate.
111 ///
112 /*--cef(source=library)--*/
113 class CefX509Certificate : public virtual CefBaseRefCounted {
114  public:
115   typedef std::vector<CefRefPtr<CefBinaryValue>> IssuerChainBinaryList;
116 
117   ///
118   // Returns the subject of the X.509 certificate. For HTTPS server
119   // certificates this represents the web server.  The common name of the
120   // subject should match the host name of the web server.
121   ///
122   /*--cef()--*/
123   virtual CefRefPtr<CefX509CertPrincipal> GetSubject() = 0;
124 
125   ///
126   // Returns the issuer of the X.509 certificate.
127   ///
128   /*--cef()--*/
129   virtual CefRefPtr<CefX509CertPrincipal> GetIssuer() = 0;
130 
131   ///
132   // Returns the DER encoded serial number for the X.509 certificate. The value
133   // possibly includes a leading 00 byte.
134   ///
135   /*--cef()--*/
136   virtual CefRefPtr<CefBinaryValue> GetSerialNumber() = 0;
137 
138   ///
139   // Returns the date before which the X.509 certificate is invalid.
140   // CefTime.GetTimeT() will return 0 if no date was specified.
141   ///
142   /*--cef()--*/
143   virtual CefTime GetValidStart() = 0;
144 
145   ///
146   // Returns the date after which the X.509 certificate is invalid.
147   // CefTime.GetTimeT() will return 0 if no date was specified.
148   ///
149   /*--cef()--*/
150   virtual CefTime GetValidExpiry() = 0;
151 
152   ///
153   // Returns the DER encoded data for the X.509 certificate.
154   ///
155   /*--cef()--*/
156   virtual CefRefPtr<CefBinaryValue> GetDEREncoded() = 0;
157 
158   ///
159   // Returns the PEM encoded data for the X.509 certificate.
160   ///
161   /*--cef()--*/
162   virtual CefRefPtr<CefBinaryValue> GetPEMEncoded() = 0;
163 
164   ///
165   // Returns the number of certificates in the issuer chain.
166   // If 0, the certificate is self-signed.
167   ///
168   /*--cef()--*/
169   virtual size_t GetIssuerChainSize() = 0;
170 
171   ///
172   // Returns the DER encoded data for the certificate issuer chain.
173   // If we failed to encode a certificate in the chain it is still
174   // present in the array but is an empty string.
175   ///
176   /*--cef(count_func=chain:GetIssuerChainSize)--*/
177   virtual void GetDEREncodedIssuerChain(IssuerChainBinaryList& chain) = 0;
178 
179   ///
180   // Returns the PEM encoded data for the certificate issuer chain.
181   // If we failed to encode a certificate in the chain it is still
182   // present in the array but is an empty string.
183   ///
184   /*--cef(count_func=chain:GetIssuerChainSize)--*/
185   virtual void GetPEMEncodedIssuerChain(IssuerChainBinaryList& chain) = 0;
186 };
187 
188 #endif  // CEF_INCLUDE_CEF_X509_CERTIFICATE_H_
189