diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-05-10 11:15:53 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-05-10 11:34:42 +0200 |
commit | 007fd2f09501eb93d74516576913e627922ef126 (patch) | |
tree | 3fbbee8730bbf77751a72a40644972b04406733f | |
parent | e9e5f07a2e956a3e5a4c3cb6fd4b0f77b1bf47bd (diff) | |
download | gnutls-007fd2f09501eb93d74516576913e627922ef126.tar.gz |
gnutls_certificate_set_key: import the DNS names of the certificates
That is, only when no (NULL) names are provided.
-rw-r--r-- | lib/gnutls_x509.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/gnutls_x509.c b/lib/gnutls_x509.c index 3d773d5ea9..f135640f14 100644 --- a/lib/gnutls_x509.c +++ b/lib/gnutls_x509.c @@ -1,5 +1,6 @@ /* - * Copyright (C) 2002-2012 Free Software Foundation, Inc. + * Copyright (C) 2002-2016 Free Software Foundation, Inc. + * Copyright (C) 2016 Red Hat, Inc. * * Author: Nikos Mavrogiannopoulos * @@ -1240,6 +1241,29 @@ gnutls_certificate_set_key(gnutls_certificate_credentials_t res, goto cleanup; } } + } else if (names == NULL && pcert_list[0].type == GNUTLS_CRT_X509) { + gnutls_x509_crt_t crt; + + ret = gnutls_x509_crt_init(&crt); + if (ret < 0) { + gnutls_assert(); + goto cleanup; + } + + ret = gnutls_x509_crt_import(crt, &pcert_list[0].cert, GNUTLS_X509_FMT_DER); + if (ret < 0) { + gnutls_assert(); + gnutls_x509_crt_deinit(crt); + goto cleanup; + } + + ret = get_x509_name(crt, &str_names); + gnutls_x509_crt_deinit(crt); + + if (ret < 0) { + gnutls_assert(); + goto cleanup; + } } if (res->pin.cb) |