Changeset 717206c in mod_gnutls


Ignore:
Timestamp:
Dec 2, 2007, 2:29:05 AM (15 years ago)
Author:
Nokis Mavrogiannopoulos <nmav@…>
Branches:
asyncio, debian/master, debian/stretch-backports, jessie-backports, main, master, msva, proxy-ticket, upstream
Children:
ee65fcb
Parents:
41f7031
git-author:
Nikos Mavrogiannopoulos <nmav@…> (12/02/07 02:29:05)
git-committer:
Nokis Mavrogiannopoulos <nmav@…> (12/02/07 02:29:05)
Message:

more fixes for subject alternative name.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gnutls_hooks.c

    r41f7031 r717206c  
    9898                       pool);
    9999    if (rv != APR_SUCCESS) {
    100         ap_log_error(APLOG_MARK, APLOG_STARTUP, rv, s,
     100        ap_log_error(APLOG_MARK, APLOG_INFO, rv, s,
    101101                     "GnuTLS failed to load params file at: %s. Will use internal params.",
    102102                     file);
     
    107107
    108108    if (rv != APR_SUCCESS) {
    109         ap_log_error(APLOG_MARK, APLOG_STARTUP, rv, s,
     109        ap_log_error(APLOG_MARK, APLOG_INFO, rv, s,
    110110                     "GnuTLS failed to stat params file at: %s", file);
    111111        return ret;
     
    116116
    117117    if (rv != APR_SUCCESS) {
    118         ap_log_error(APLOG_MARK, APLOG_STARTUP, rv, s,
     118        ap_log_error(APLOG_MARK, APLOG_INFO, rv, s,
    119119                     "GnuTLS failed to read params file at: %s", file);
    120120        return ret;
     
    210210 * Returns negative on error.
    211211 */
    212 static int read_crt_cn(apr_pool_t * p, gnutls_x509_crt cert,
     212static int read_crt_cn(server_rec *s, apr_pool_t * p, gnutls_x509_crt cert,
    213213                       char **cert_cn)
    214214{
     
    228228                  GNUTLS_OID_X520_COMMON_NAME, 0, 0, *cert_cn, &data_len);
    229229    } else {                    /* No CN return subject alternative name */
    230 
     230        ap_log_error(APLOG_MARK, APLOG_INFO, 0, s,
     231                     "No common name found in certificate for '%s:%d'. Looking for subject alternative name.",
     232                     s->server_hostname, s->port);
     233        rv = 0;
    231234        /* read subject alternative name */
    232235        for (i = 0; !(rv < 0); i++) {
    233236            rv = gnutls_x509_crt_get_subject_alt_name(cert, i,
    234237                    NULL, &data_len, NULL);
    235                    
    236             if (rv == GNUTLS_SAN_DNSNAME) {
    237                 *cert_cn = apr_palloc(p, data_len);
    238                 rv = gnutls_x509_crt_get_subject_alt_name(cert, i,
    239                     *cert_cn, &data_len, NULL);
    240                 break;
    241 
    242             }
     238
     239            if (rv == GNUTLS_E_SHORT_MEMORY_BUFFER && data_len > 1) {
     240                /* FIXME: not very efficient. What if we have several alt names
     241                 * before DNSName?
     242                 */
     243                *cert_cn = apr_palloc(p, data_len+1);
     244               
     245                rv = gnutls_x509_crt_get_subject_alt_name(cert, i,
     246                  *cert_cn, &data_len, NULL);
     247                (*cert_cn)[data_len]=0;
     248
     249                if (rv == GNUTLS_SAN_DNSNAME)
     250                  break;
     251            }
    243252        }
    244253    }
     
    387396
    388397            if (sc->enabled == GNUTLS_ENABLED_TRUE) {
    389                 rv = read_crt_cn(p, sc->cert_x509, &sc->cert_cn);
     398                rv = read_crt_cn(s, p, sc->cert_x509, &sc->cert_cn);
    390399                if (rv < 0) {
    391400                    ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s,
    392                              "[GnuTLS] - Cannot find a certificate for host '%s:%d'! Disabling TLS.",
     401                             "[GnuTLS] - Cannot find a certificate for host '%s:%d'!",
    393402                             s->server_hostname, s->port);
    394                     sc->enabled = GNUTLS_ENABLED_FALSE;
    395403                    sc->cert_cn = NULL;
    396404                    continue;
     
    488496         */
    489497        return 1;
     498    } else {
     499#if MOD_GNUTLS_DEBUG
     500        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0,
     501                     x->ctxt->c->base_server,
     502                     "GnuTLS: Virtual Host CB: "
     503                     "'%s' != '%s'", tsc->cert_cn, x->sni_name);
     504#endif
     505   
    490506    }
    491507    return 0;
Note: See TracChangeset for help on using the changeset viewer.