@@ -135,76 +135,6 @@ SSLSessionPointer GetTLSSession(const unsigned char* buf, size_t length) {
135
135
return SSLSessionPointer (d2i_SSL_SESSION (nullptr , &buf, length));
136
136
}
137
137
138
- std::unordered_multimap<std::string, std::string>
139
- GetCertificateAltNames (X509* cert) {
140
- std::unordered_multimap<std::string, std::string> map;
141
- BIOPointer bio (BIO_new (BIO_s_mem ()));
142
- BUF_MEM* mem;
143
- int idx = X509_get_ext_by_NID (cert, NID_subject_alt_name, -1 );
144
- if (idx < 0 ) // There is no subject alt name
145
- return map;
146
-
147
- X509_EXTENSION* ext = X509_get_ext (cert, idx);
148
- CHECK_NOT_NULL (ext);
149
- const X509V3_EXT_METHOD* method = X509V3_EXT_get (ext);
150
- CHECK_EQ (method, X509V3_EXT_get_nid (NID_subject_alt_name));
151
-
152
- GENERAL_NAMES* names = static_cast <GENERAL_NAMES*>(X509V3_EXT_d2i (ext));
153
- if (names == nullptr ) // There are no names
154
- return map;
155
-
156
- for (int i = 0 ; i < sk_GENERAL_NAME_num (names); i++) {
157
- USE (BIO_reset (bio.get ()));
158
- GENERAL_NAME* gen = sk_GENERAL_NAME_value (names, i);
159
- if (gen->type == GEN_DNS) {
160
- ASN1_IA5STRING* name = gen->d .dNSName ;
161
- BIO_write (bio.get (), name->data , name->length );
162
- BIO_get_mem_ptr (bio.get (), &mem);
163
- map.emplace (" dns" , std::string (mem->data , mem->length ));
164
- } else {
165
- STACK_OF (CONF_VALUE)* nval = i2v_GENERAL_NAME (
166
- const_cast <X509V3_EXT_METHOD*>(method), gen, nullptr );
167
- if (nval == nullptr )
168
- continue ;
169
- X509V3_EXT_val_prn (bio.get (), nval, 0 , 0 );
170
- sk_CONF_VALUE_pop_free (nval, X509V3_conf_free);
171
- BIO_get_mem_ptr (bio.get (), &mem);
172
- std::string value (mem->data , mem->length );
173
- if (value.compare (0 , 11 , " IP Address:" ) == 0 ) {
174
- map.emplace (" ip" , value.substr (11 ));
175
- } else if (value.compare (0 , 4 , " URI:" ) == 0 ) {
176
- url::URL url (value.substr (4 ));
177
- if (url.flags () & url::URL_FLAGS_CANNOT_BE_BASE ||
178
- url.flags () & url::URL_FLAGS_FAILED) {
179
- continue ; // Skip this one
180
- }
181
- map.emplace (" uri" , url.host ());
182
- }
183
- }
184
- }
185
- sk_GENERAL_NAME_pop_free (names, GENERAL_NAME_free);
186
- return map;
187
- }
188
-
189
- std::string GetCertificateCN (X509* cert) {
190
- X509_NAME* subject = X509_get_subject_name (cert);
191
- if (subject != nullptr ) {
192
- int nid = OBJ_txt2nid (" CN" );
193
- int idx = X509_NAME_get_index_by_NID (subject, nid, -1 );
194
- if (idx != -1 ) {
195
- X509_NAME_ENTRY* cn = X509_NAME_get_entry (subject, idx);
196
- if (cn != nullptr ) {
197
- ASN1_STRING* cn_str = X509_NAME_ENTRY_get_data (cn);
198
- if (cn_str != nullptr ) {
199
- return std::string (reinterpret_cast <const char *>(
200
- ASN1_STRING_get0_data (cn_str)));
201
- }
202
- }
203
- }
204
- }
205
- return std::string ();
206
- }
207
-
208
138
long VerifyPeerCertificate ( // NOLINT(runtime/int)
209
139
const SSLPointer& ssl,
210
140
long def) { // NOLINT(runtime/int)
0 commit comments