MCPcopy Create free account
hub / github.com/apache/trafficserver / check_names

Function check_names

tests/tools/plugins/ssl_client_verify_test.cc:55–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55bool
56check_names(X509 *cert)
57{
58 bool retval = false;
59
60 // Check the common name
61 X509_NAME *subject = X509_get_subject_name(cert);
62 if (subject) {
63 int pos = -1;
64 for (; !retval;) {
65 pos = X509_NAME_get_index_by_NID(subject, NID_commonName, pos);
66 if (pos == -1) {
67 break;
68 }
69
70 X509_NAME_ENTRY *e = X509_NAME_get_entry(subject, pos);
71 ASN1_STRING *cn = X509_NAME_ENTRY_get_data(e);
72 char *subj_name = strndup(reinterpret_cast<const char *>(ASN1_STRING_get0_data(cn)), ASN1_STRING_length(cn));
73 retval = check_name(subj_name);
74 free(subj_name);
75 }
76 }
77 if (!retval) {
78 // Check the subjectAltNanes (if present)
79 GENERAL_NAMES *names = static_cast<GENERAL_NAMES *>(X509_get_ext_d2i(cert, NID_subject_alt_name, nullptr, nullptr));
80 if (names) {
81 unsigned count = sk_GENERAL_NAME_num(names);
82 for (unsigned i = 0; i < count && !retval; ++i) {
83 GENERAL_NAME *name;
84
85 name = sk_GENERAL_NAME_value(names, i);
86 if (name->type == GEN_DNS) {
87 char *dns =
88 strndup(reinterpret_cast<const char *>(ASN1_STRING_get0_data(name->d.dNSName)), ASN1_STRING_length(name->d.dNSName));
89 retval = check_name(dns);
90 free(dns);
91 }
92 }
93 GENERAL_NAMES_free(names);
94 }
95 }
96 return retval;
97}
98
99int
100CB_client_verify(TSCont cont, TSEvent event, void *edata)

Callers 1

CB_client_verifyFunction · 0.85

Calls 1

check_nameFunction · 0.85

Tested by

no test coverage detected