SSLClient  v1.5.0
SSLClientParameters.h
Go to the documentation of this file.
1 /* Copyright 2019 OSU OPEnS Lab
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy of this
4  * software and associated documentation files (the "Software"), to deal in the Software
5  * without restriction, including without limitation the rights to use, copy, modify,
6  * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7  * permit persons to whom the Software is furnished to do so, subject to the following
8  * conditions:
9  *
10  * The above copyright notice and this permission notice shall be included in all
11  * copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
15  * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
16  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
18  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19  */
20 
28 #include "bearssl.h"
29 #undef min
30 #undef max
31 #include <vector>
32 
33 #ifndef SSLClientParameters_H_
34 #define SSLClientParameters_H_
35 
53 public:
84  static SSLClientParameters fromPEM(const char* cert_pem, const size_t cert_len, const char* key_pem, const size_t key_len);
85 
112  static SSLClientParameters fromDER(const char* cert_der, const size_t cert_len, const char* key_der, const size_t key_len);
113 
115  const br_x509_certificate* getCertChain() const { return &m_cert_struct; }
116 
118  int getCertType() const { return br_skey_decoder_key_type(&m_key_struct); }
119 
121  const br_ec_private_key* getECKey() const { return br_skey_decoder_get_ec(&m_key_struct); }
122 
124  const br_rsa_private_key* getRSAKey() const { return br_skey_decoder_get_rsa(&m_key_struct); }
125 
126 protected:
127  SSLClientParameters(const char* cert, const size_t cert_len, const char* key, const size_t key_len, bool is_der);
128 
129 private:
130  const std::vector<char> m_cert;
131  const br_x509_certificate m_cert_struct;
132  const br_skey_decoder_context m_key_struct;
133 };
134 
135 #endif
int getCertType() const
Definition: SSLClientParameters.h:118
static SSLClientParameters fromDER(const char *cert_der, const size_t cert_len, const char *key_der, const size_t key_len)
Create mutual authentication parameters from a DER certificate and private key.
Definition: SSLClientParameters.cpp:92
static SSLClientParameters fromPEM(const char *cert_pem, const size_t cert_len, const char *key_pem, const size_t key_len)
Create mutual authentication parameters from a PEM certificate and private key.
Definition: SSLClientParameters.cpp:87
const br_rsa_private_key * getRSAKey() const
Definition: SSLClientParameters.h:124
SSLClientParameters(const char *cert, const size_t cert_len, const char *key, const size_t key_len, bool is_der)
Definition: SSLClientParameters.cpp:81
const br_x509_certificate * getCertChain() const
Definition: SSLClientParameters.h:115
This class stores data required for SSLClient to use mutual authentication.
Definition: SSLClientParameters.h:52
const br_ec_private_key * getECKey() const
Definition: SSLClientParameters.h:121