diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2014-07-21 16:55:09 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2014-07-21 16:57:40 +0200 |
commit | 5cf2152c0609238925b5be5e63bd52b15064f7bb (patch) | |
tree | 758b563e6528deab71909bbc5125a4aab85372a2 | |
parent | 2835f52e3e347b28d3a50205c8289313345c6d14 (diff) | |
download | gnutls-5cf2152c0609238925b5be5e63bd52b15064f7bb.tar.gz |
Added gnutls_certificate_set_x509_trust_dir()
-rw-r--r-- | lib/gnutls_x509.c | 29 | ||||
-rw-r--r-- | lib/includes/gnutls/gnutls.h.in | 5 | ||||
-rw-r--r-- | lib/libgnutls.map | 1 |
3 files changed, 35 insertions, 0 deletions
diff --git a/lib/gnutls_x509.c b/lib/gnutls_x509.c index 6649a35628..39898c5bf2 100644 --- a/lib/gnutls_x509.c +++ b/lib/gnutls_x509.c @@ -1563,6 +1563,35 @@ int ret; } /** + * gnutls_certificate_set_x509_trust_dir: + * @cred: is a #gnutls_certificate_credentials_t structure. + * @ca_dir: is a directory containing the list of trusted CAs (DER or PEM list) + * @type: is PEM or DER + * + * This function adds the trusted CAs present in the directory in order to + * verify client or server certificates. This function is identical + * to gnutls_certificate_set_x509_trust_file() but loads all certificates + * in a directory. + * + * Returns: number of certificates processed, or a negative error code on + * error. + **/ +int +gnutls_certificate_set_x509_trust_dir(gnutls_certificate_credentials_t cred, + const char *ca_dir, + gnutls_x509_crt_fmt_t type) +{ +int ret; + + ret = gnutls_x509_trust_list_add_trust_dir(cred->tlist, ca_dir, NULL, + type, GNUTLS_TL_USE_IN_TLS, 0); + if (ret == GNUTLS_E_NO_CERTIFICATE_FOUND) + return 0; + + return ret; +} + +/** * gnutls_certificate_set_x509_system_trust: * @cred: is a #gnutls_certificate_credentials_t structure. * diff --git a/lib/includes/gnutls/gnutls.h.in b/lib/includes/gnutls/gnutls.h.in index 4d45f1ea95..471fd7b65a 100644 --- a/lib/includes/gnutls/gnutls.h.in +++ b/lib/includes/gnutls/gnutls.h.in @@ -1351,6 +1351,11 @@ int gnutls_certificate_set_x509_trust_file(gnutls_certificate_credentials_t cred, const char *cafile, gnutls_x509_crt_fmt_t type); +int +gnutls_certificate_set_x509_trust_dir(gnutls_certificate_credentials_t cred, + const char *ca_dir, + gnutls_x509_crt_fmt_t type); + int gnutls_certificate_set_x509_trust_mem(gnutls_certificate_credentials_t res, const gnutls_datum_t * ca, gnutls_x509_crt_fmt_t type); diff --git a/lib/libgnutls.map b/lib/libgnutls.map index 5399f6d6d0..94b64d37be 100644 --- a/lib/libgnutls.map +++ b/lib/libgnutls.map @@ -1013,6 +1013,7 @@ GNUTLS_3_1_0 { gnutls_record_recv_packet; gnutls_packet_get; gnutls_x509_trust_list_add_trust_dir; + gnutls_certificate_set_x509_trust_dir; } GNUTLS_3_0_0; GNUTLS_FIPS140 { |