MCPcopy Create free account
hub / github.com/catboost/catboost / MatchCertCommonName

Function MatchCertCommonName

library/cpp/neh/https.cpp:308–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306 }
307
308 EMatchResult MatchCertCommonName(X509* cert, TStringBuf hostname) {
309 int commonNameLoc = X509_NAME_get_index_by_NID(X509_get_subject_name(cert), NID_commonName, -1);
310 if (commonNameLoc < 0) {
311 return ERROR;
312 }
313
314 X509_NAME_ENTRY* commonNameEntry = X509_NAME_get_entry(X509_get_subject_name(cert), commonNameLoc);
315 if (!commonNameEntry) {
316 return ERROR;
317 }
318
319 ASN1_STRING* commonNameAsn1 = X509_NAME_ENTRY_get_data(commonNameEntry);
320 if (!commonNameAsn1) {
321 return ERROR;
322 }
323
324 TStringBuf commonName((const char*)ASN1_STRING_get0_data(commonNameAsn1), ASN1_STRING_length(commonNameAsn1));
325
326 return MatchDomainName(commonName, hostname)
327 ? MATCH_FOUND
328 : NO_MATCH;
329 }
330
331 bool CheckCertHostname(X509* cert, TStringBuf hostname) {
332 switch (MatchCertAltNames(cert, hostname)) {

Callers 1

CheckCertHostnameFunction · 0.85

Calls 1

MatchDomainNameFunction · 0.85

Tested by

no test coverage detected