2 ===================================================================
5 @@ -447,8 +447,17 @@ ssl_check_cert_ident(X509 * x, char *hos
8 seen_dnsname = Strnew();
9 + /* replace \0 to make full string visible to user */
10 + if (sl != strlen(sn)) {
12 + for (i = 0; i < sl; ++i) {
17 Strcat_m_charp(seen_dnsname, sn, " ", NULL);
18 - if (ssl_match_cert_ident(sn, sl, hostname))
19 + if (sl == strlen(sn) /* catch \0 in SAN */
20 + && ssl_match_cert_ident(sn, sl, hostname))
24 @@ -466,16 +475,27 @@ ssl_check_cert_ident(X509 * x, char *hos
25 if (match_ident == FALSE && ret == NULL) {
30 xn = X509_get_subject_name(x);
32 - if (X509_NAME_get_text_by_NID(xn, NID_commonName,
33 - buf, sizeof(buf)) == -1)
34 + slen = X509_NAME_get_text_by_NID(xn, NID_commonName, buf, sizeof(buf));
36 /* FIXME: gettextize? */
37 ret = Strnew_charp("Unable to get common name from peer cert");
38 - else if (!ssl_match_cert_ident(buf, strlen(buf), hostname))
39 + else if (slen != strlen(buf)
40 + || !ssl_match_cert_ident(buf, strlen(buf), hostname)) {
41 + /* replace \0 to make full string visible to user */
42 + if (slen != strlen(buf)) {
44 + for (i = 0; i < slen; ++i) {
49 /* FIXME: gettextize? */
50 ret = Sprintf("Bad cert ident %s from %s", buf, hostname);