2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2007 Colin Leroy <colin@colino.net>
4 * and the Claws Mail team
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
27 #include <openssl/ssl.h>
29 #include <gnutls/gnutls.h>
30 #include <gnutls/x509.h>
31 #include <gnutls/pkcs12.h>
36 #include <sys/types.h>
39 #include <glib/gi18n.h>
41 # include <winsock2.h>
43 # include <sys/socket.h>
44 # include <netinet/in.h>
46 #endif /* G_OS_WIN32 */
47 #include "ssl_certificate.h"
54 static GHashTable *warned_expired = NULL;
56 gboolean prefs_common_unsafe_ssl_certs(void);
58 static gchar *get_certificate_path(const gchar *host, const gchar *port, const gchar *fp)
60 if (fp != NULL && prefs_common_unsafe_ssl_certs())
61 return g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
62 "certs", G_DIR_SEPARATOR_S,
63 host, ".", port, ".", fp, ".cert", NULL);
65 return g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
66 "certs", G_DIR_SEPARATOR_S,
67 host, ".", port, ".cert", NULL);
71 static SSLCertificate *ssl_certificate_new_lookup(X509 *x509_cert, gchar *host, gushort port, gboolean lookup);
73 static SSLCertificate *ssl_certificate_new_lookup(gnutls_x509_crt x509_cert, gchar *host, gushort port, gboolean lookup);
77 time_t asn1toTime(ASN1_TIME *asn1Time)
82 if (asn1Time == NULL || asn1Time->length < 13)
85 memset(&tm, 0, sizeof(tm));
87 #define N2(n) ((asn1Time->data[n]-'0')*10 + asn1Time->data[(n)+1]-'0')
89 #define CPY(f,n) (tm.f=N2(n))
94 tm.tm_year += 100; /* Sux */
105 if (asn1Time->data[12] != 'Z')
107 if (asn1Time->length < 17)
110 offset=N2(13)*3600+N2(15)*60;
112 if (asn1Time->data[12] == '-')
119 return mktime(&tm)-offset;
123 static char * get_fqdn(char *host)
127 struct addrinfo hints, *res;
132 if (host == NULL || strlen(host) == 0)
135 memset(&hints, 0, sizeof(hints));
136 hints.ai_flags = AI_CANONNAME;
137 hints.ai_family = AF_UNSPEC;
138 hints.ai_socktype = SOCK_STREAM;
139 hints.ai_protocol = IPPROTO_TCP;
141 gai_err = getaddrinfo(host, NULL, &hints, &res);
143 g_warning("getaddrinfo for %s failed: %s\n",
144 host, gai_strerror(gai_err));
145 return g_strdup(host);
148 if (res->ai_canonname && strlen(res->ai_canonname)) {
149 gchar *fqdn = g_strdup(res->ai_canonname);
154 return g_strdup(host);
157 return g_strdup(host);
160 hp = my_gethostbyname(host);
162 return g_strdup(host); /*caller should free*/
164 return g_strdup(hp->h_name);
168 char * readable_fingerprint(unsigned char *src, int len)
179 tmp2 = g_strdup_printf("%s:%02X", ret, src[i]);
181 tmp2 = g_strdup_printf("%02X", src[i]);
183 ret = g_strdup(tmp2);
191 static gnutls_x509_crt x509_crt_copy(gnutls_x509_crt src)
196 gnutls_x509_crt dest;
198 if (gnutls_x509_crt_init(&dest) != 0) {
199 g_warning("couldn't gnutls_x509_crt_init\n");
203 if (gnutls_x509_crt_export(src, GNUTLS_X509_FMT_DER, NULL, &size)
204 != GNUTLS_E_SHORT_MEMORY_BUFFER) {
205 g_warning("couldn't gnutls_x509_crt_export to get size\n");
206 gnutls_x509_crt_deinit(dest);
210 tmp.data = malloc(size);
211 memset(tmp.data, 0, size);
212 ret = gnutls_x509_crt_export(src, GNUTLS_X509_FMT_DER, tmp.data, &size);
215 ret = gnutls_x509_crt_import(dest, &tmp, GNUTLS_X509_FMT_DER);
217 g_warning("couldn't gnutls_x509_crt_import for real (%d %s)\n", ret, gnutls_strerror(ret));
218 gnutls_x509_crt_deinit(dest);
222 g_warning("couldn't gnutls_x509_crt_export for real (%d %s)\n", ret, gnutls_strerror(ret));
223 gnutls_x509_crt_deinit(dest);
233 static SSLCertificate *ssl_certificate_new_lookup(X509 *x509_cert, gchar *host, gushort port, gboolean lookup)
235 static SSLCertificate *ssl_certificate_new_lookup(gnutls_x509_crt x509_cert, gchar *host, gushort port, gboolean lookup)
238 SSLCertificate *cert = g_new0(SSLCertificate, 1);
240 unsigned char md[128];
242 if (host == NULL || x509_cert == NULL) {
243 ssl_certificate_destroy(cert);
247 cert->x509_cert = X509_dup(x509_cert);
249 cert->x509_cert = x509_crt_copy(x509_cert);
250 cert->status = (guint)-1;
253 cert->host = get_fqdn(host);
255 cert->host = g_strdup(host);
260 X509_digest(cert->x509_cert, EVP_md5(), md, &n);
261 cert->fingerprint = readable_fingerprint(md, (int)n);
264 gnutls_x509_crt_get_fingerprint(cert->x509_cert, GNUTLS_DIG_MD5, md, &n);
265 cert->fingerprint = readable_fingerprint(md, (int)n);
271 static void gnutls_i2d_X509_fp(FILE *fp, gnutls_x509_crt x509_cert)
273 char output[10*1024];
274 size_t cert_size = 10*1024;
277 if ((r = gnutls_x509_crt_export(x509_cert, GNUTLS_X509_FMT_DER, output, &cert_size)) < 0) {
278 g_warning("couldn't export cert %s (%d)\n", gnutls_strerror(r), cert_size);
281 debug_print("writing %zd bytes\n",cert_size);
282 if (fwrite(&output, 1, cert_size, fp) < cert_size) {
283 g_warning("failed to write cert\n");
287 size_t gnutls_i2d_X509(gnutls_x509_crt x509_cert, unsigned char **output)
289 size_t cert_size = 10*1024;
295 *output = malloc(cert_size);
297 if ((r = gnutls_x509_crt_export(x509_cert, GNUTLS_X509_FMT_DER, *output, &cert_size)) < 0) {
298 g_warning("couldn't export cert %s (%d)\n", gnutls_strerror(r), cert_size);
306 size_t gnutls_i2d_PrivateKey(gnutls_x509_privkey pkey, unsigned char **output)
308 size_t key_size = 10*1024;
314 *output = malloc(key_size);
316 if ((r = gnutls_x509_privkey_export(pkey, GNUTLS_X509_FMT_DER, *output, &key_size)) < 0) {
317 g_warning("couldn't export key %s (%d)\n", gnutls_strerror(r), key_size);
325 static gnutls_x509_crt gnutls_d2i_X509_fp(FILE *fp, int format)
327 gnutls_x509_crt cert = NULL;
331 if (fstat(fileno(fp), &s) < 0) {
335 tmp.data = malloc(s.st_size);
336 memset(tmp.data, 0, s.st_size);
337 tmp.size = s.st_size;
338 if (fread (tmp.data, 1, s.st_size, fp) < s.st_size) {
344 gnutls_x509_crt_init(&cert);
345 if ((r = gnutls_x509_crt_import(cert, &tmp, (format == 0)?GNUTLS_X509_FMT_DER:GNUTLS_X509_FMT_PEM)) < 0) {
346 debug_print("cert import failed: %s\n", gnutls_strerror(r));
347 gnutls_x509_crt_deinit(cert);
351 debug_print("got cert! %p\n", cert);
355 static gnutls_x509_privkey gnutls_d2i_key_fp(FILE *fp, int format)
357 gnutls_x509_privkey key = NULL;
361 if (fstat(fileno(fp), &s) < 0) {
365 tmp.data = malloc(s.st_size);
366 memset(tmp.data, 0, s.st_size);
367 tmp.size = s.st_size;
368 if (fread (tmp.data, 1, s.st_size, fp) < s.st_size) {
374 gnutls_x509_privkey_init(&key);
375 if ((r = gnutls_x509_privkey_import(key, &tmp, (format == 0)?GNUTLS_X509_FMT_DER:GNUTLS_X509_FMT_PEM)) < 0) {
376 debug_print("key import failed: %s\n", gnutls_strerror(r));
377 gnutls_x509_privkey_deinit(key);
381 debug_print("got key! %p\n", key);
385 static gnutls_pkcs12_t gnutls_d2i_PKCS12_fp(FILE *fp, int format)
387 gnutls_pkcs12_t p12 = NULL;
391 if (fstat(fileno(fp), &s) < 0) {
395 tmp.data = malloc(s.st_size);
396 memset(tmp.data, 0, s.st_size);
397 tmp.size = s.st_size;
398 if (fread (tmp.data, 1, s.st_size, fp) < s.st_size) {
404 gnutls_pkcs12_init(&p12);
406 if ((r = gnutls_pkcs12_import(p12, &tmp, (format == 0)?GNUTLS_X509_FMT_DER:GNUTLS_X509_FMT_PEM,0)) < 0) {
407 g_warning("p12 import failed: %s\n", gnutls_strerror(r));
408 gnutls_pkcs12_deinit(p12);
412 debug_print("got p12! %p\n", p12);
418 static void ssl_certificate_save (SSLCertificate *cert)
423 file = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
424 "certs", G_DIR_SEPARATOR_S, NULL);
426 if (!is_dir_exist(file))
430 port = g_strdup_printf("%d", cert->port);
431 file = get_certificate_path(cert->host, port, cert->fingerprint);
434 fp = g_fopen(file, "wb");
437 debug_print("Can't save certificate !\n");
441 gnutls_i2d_X509_fp(fp, cert->x509_cert);
443 i2d_X509_fp(fp, cert->x509_cert);
450 void ssl_certificate_destroy(SSLCertificate *cert)
457 X509_free(cert->x509_cert);
459 gnutls_x509_crt_deinit(cert->x509_cert);
462 g_free(cert->fingerprint);
467 void ssl_certificate_delete_from_disk(SSLCertificate *cert)
471 buf = g_strdup_printf("%d", cert->port);
472 file = get_certificate_path(cert->host, buf, cert->fingerprint);
478 SSLCertificate *ssl_certificate_find (gchar *host, gushort port, const gchar *fingerprint)
480 return ssl_certificate_find_lookup (host, port, fingerprint, TRUE);
483 SSLCertificate *ssl_certificate_find_lookup (gchar *host, gushort port, const gchar *fingerprint, gboolean lookup)
488 SSLCertificate *cert = NULL;
492 gnutls_x509_crt tmp_x509;
495 gboolean must_rename = FALSE;
498 fqdn_host = get_fqdn(host);
500 fqdn_host = g_strdup(host);
502 buf = g_strdup_printf("%d", port);
504 if (fingerprint != NULL) {
505 file = get_certificate_path(fqdn_host, buf, fingerprint);
506 fp = g_fopen(file, "rb");
509 /* see if we have the old one */
510 debug_print("didn't get %s\n", file);
512 file = get_certificate_path(fqdn_host, buf, NULL);
513 fp = g_fopen(file, "rb");
516 debug_print("got %s\n", file);
517 must_rename = (fingerprint != NULL);
520 debug_print("got %s first try\n", file);
530 if ((tmp_x509 = d2i_X509_fp(fp, 0)) != NULL) {
532 if ((tmp_x509 = gnutls_d2i_X509_fp(fp, 0)) != NULL) {
534 cert = ssl_certificate_new_lookup(tmp_x509, fqdn_host, port, lookup);
535 debug_print("got cert %p\n", cert);
539 gnutls_x509_crt_deinit(tmp_x509);
546 gchar *old = get_certificate_path(fqdn_host, buf, NULL);
547 gchar *new = get_certificate_path(fqdn_host, buf, fingerprint);
548 if (strcmp(old, new))
549 move_file(old, new, TRUE);
559 static gboolean ssl_certificate_compare (SSLCertificate *cert_a, SSLCertificate *cert_b)
562 if (cert_a == NULL || cert_b == NULL)
564 else if (!X509_cmp(cert_a->x509_cert, cert_b->x509_cert))
571 size_t cert_size_a = 0, cert_size_b = 0;
574 if (cert_a == NULL || cert_b == NULL)
577 if ((r = gnutls_x509_crt_export(cert_a->x509_cert, GNUTLS_X509_FMT_DER, NULL, &cert_size_a))
578 != GNUTLS_E_SHORT_MEMORY_BUFFER) {
579 g_warning("couldn't gnutls_x509_crt_export to get size a %s\n", gnutls_strerror(r));
583 if ((r = gnutls_x509_crt_export(cert_b->x509_cert, GNUTLS_X509_FMT_DER, NULL, &cert_size_b))
584 != GNUTLS_E_SHORT_MEMORY_BUFFER) {
585 g_warning("couldn't gnutls_x509_crt_export to get size b %s\n", gnutls_strerror(r));
589 output_a = malloc(cert_size_a);
590 output_b = malloc(cert_size_b);
591 if ((r = gnutls_x509_crt_export(cert_a->x509_cert, GNUTLS_X509_FMT_DER, output_a, &cert_size_a)) < 0) {
592 g_warning("couldn't gnutls_x509_crt_export a %s\n", gnutls_strerror(r));
597 if ((r = gnutls_x509_crt_export(cert_b->x509_cert, GNUTLS_X509_FMT_DER, output_b, &cert_size_b)) < 0) {
598 g_warning("couldn't gnutls_x509_crt_export b %s\n", gnutls_strerror(r));
603 if (cert_size_a != cert_size_b) {
604 g_warning("size differ %d %d\n", cert_size_a, cert_size_b);
609 if (memcmp(output_a, output_b, cert_size_a)) {
610 g_warning("contents differ\n");
623 char *ssl_certificate_check_signer (X509 *cert)
625 X509_STORE_CTX store_ctx;
626 X509_STORE *store = SSL_CTX_get_cert_store(ssl_get_ctx());
627 char *err_msg = NULL;
630 g_print("Can't create X509_STORE\n");
634 X509_STORE_CTX_init (&store_ctx, store, cert, NULL);
636 if(!X509_verify_cert (&store_ctx)) {
637 err_msg = g_strdup(X509_verify_cert_error_string(
638 X509_STORE_CTX_get_error(&store_ctx)));
639 debug_print("Can't check signer: %s\n", err_msg);
640 X509_STORE_CTX_cleanup (&store_ctx);
644 X509_STORE_CTX_cleanup (&store_ctx);
648 char *ssl_certificate_check_signer (gnutls_x509_crt cert, guint status)
650 if (status == (guint)-1)
651 return g_strdup(_("Uncheckable"));
653 if (status & GNUTLS_CERT_INVALID) {
654 if (gnutls_x509_crt_check_issuer(cert, cert))
655 return g_strdup(_("Self-signed certificate"));
657 if (status & GNUTLS_CERT_REVOKED)
658 return g_strdup(_("Revoked certificate"));
659 if (status & GNUTLS_CERT_SIGNER_NOT_FOUND)
660 return g_strdup(_("No certificate issuer found"));
661 if (status & GNUTLS_CERT_SIGNER_NOT_CA)
662 return g_strdup(_("Certificate issuer is not a CA"));
670 gboolean ssl_certificate_check (X509 *x509_cert, gchar *fqdn, gchar *host, gushort port)
672 gboolean ssl_certificate_check (gnutls_x509_crt x509_cert, guint status, gchar *fqdn, gchar *host, gushort port)
675 SSLCertificate *current_cert = NULL;
676 SSLCertificate *known_cert;
677 SSLCertHookData cert_hook_data;
678 gchar *fqdn_host = NULL;
681 unsigned char md[128];
684 fqdn_host = g_strdup(fqdn);
686 fqdn_host = get_fqdn(host);
688 g_warning("no host!\n");
692 current_cert = ssl_certificate_new_lookup(x509_cert, fqdn_host, port, FALSE);
694 if (current_cert == NULL) {
695 debug_print("Buggy certificate !\n");
701 current_cert->status = status;
705 X509_digest(x509_cert, EVP_md5(), md, &n);
706 fingerprint = readable_fingerprint(md, (int)n);
709 gnutls_x509_crt_get_fingerprint(x509_cert, GNUTLS_DIG_MD5, md, &n);
710 fingerprint = readable_fingerprint(md, (int)n);
713 known_cert = ssl_certificate_find_lookup (fqdn_host, port, fingerprint, FALSE);
718 if (known_cert == NULL) {
719 cert_hook_data.cert = current_cert;
720 cert_hook_data.old_cert = NULL;
721 cert_hook_data.expired = FALSE;
722 cert_hook_data.accept = FALSE;
724 hooks_invoke(SSLCERT_ASK_HOOKLIST, &cert_hook_data);
726 if (!cert_hook_data.accept) {
727 ssl_certificate_destroy(current_cert);
730 ssl_certificate_save(current_cert);
731 ssl_certificate_destroy(current_cert);
734 } else if (!ssl_certificate_compare (current_cert, known_cert)) {
735 cert_hook_data.cert = current_cert;
736 cert_hook_data.old_cert = known_cert;
737 cert_hook_data.expired = FALSE;
738 cert_hook_data.accept = FALSE;
740 hooks_invoke(SSLCERT_ASK_HOOKLIST, &cert_hook_data);
742 if (!cert_hook_data.accept) {
743 ssl_certificate_destroy(current_cert);
744 ssl_certificate_destroy(known_cert);
747 ssl_certificate_save(current_cert);
748 ssl_certificate_destroy(current_cert);
749 ssl_certificate_destroy(known_cert);
753 } else if (asn1toTime(X509_get_notAfter(current_cert->x509_cert)) < time(NULL)) {
755 } else if (gnutls_x509_crt_get_expiration_time(current_cert->x509_cert) < time(NULL)) {
757 gchar *tmp = g_strdup_printf("%s:%d", current_cert->host, current_cert->port);
759 if (warned_expired == NULL)
760 warned_expired = g_hash_table_new(g_str_hash, g_str_equal);
762 if (g_hash_table_lookup(warned_expired, tmp)) {
764 ssl_certificate_destroy(current_cert);
765 ssl_certificate_destroy(known_cert);
769 cert_hook_data.cert = current_cert;
770 cert_hook_data.old_cert = NULL;
771 cert_hook_data.expired = TRUE;
772 cert_hook_data.accept = FALSE;
774 hooks_invoke(SSLCERT_ASK_HOOKLIST, &cert_hook_data);
776 if (!cert_hook_data.accept) {
778 ssl_certificate_destroy(current_cert);
779 ssl_certificate_destroy(known_cert);
782 g_hash_table_insert(warned_expired, tmp, GINT_TO_POINTER(1));
783 ssl_certificate_destroy(current_cert);
784 ssl_certificate_destroy(known_cert);
789 ssl_certificate_destroy(current_cert);
790 ssl_certificate_destroy(known_cert);
795 X509 *ssl_certificate_get_x509_from_pem_file(const gchar *file)
800 if (is_file_exist(file)) {
801 FILE *fp = g_fopen(file, "r");
803 x509 = PEM_read_X509(fp, NULL, NULL, NULL);
808 log_error(LOG_PROTOCOL, "Can not open certificate file %s\n", file);
813 static int ssl_pkey_password_cb(char *buf, int max_len, int flag, void *pwd)
818 EVP_PKEY *ssl_certificate_get_pkey_from_pem_file(const gchar *file)
820 EVP_PKEY *pkey = NULL;
823 if (is_file_exist(file)) {
824 FILE *fp = g_fopen(file, "r");
826 pkey = PEM_read_PrivateKey(fp, NULL, ssl_pkey_password_cb, NULL);
831 log_error(LOG_PROTOCOL, "Can not open private key file %s\n", file);
836 void ssl_certificate_get_x509_and_pkey_from_p12_file(const gchar *file, const gchar *password,
837 X509 **x509, EVP_PKEY **pkey)
846 if (is_file_exist(file)) {
847 FILE *fp = g_fopen(file, "r");
849 p12 = d2i_PKCS12_fp(fp, NULL);
853 log_error(LOG_PROTOCOL, "Can not open certificate file %s\n", file);
856 if (PKCS12_parse(p12, password, pkey, x509, NULL) == 1) {
857 /* we got the correct password */
860 hooks_invoke(SSL_CERT_GET_PASSWORD, &tmp);
861 if (PKCS12_parse(p12, tmp, pkey, x509, NULL) == 1) {
862 debug_print("got p12\n");
864 log_error(LOG_PROTOCOL, "%s\n", ERR_error_string(ERR_get_error(),NULL));
873 gnutls_x509_crt ssl_certificate_get_x509_from_pem_file(const gchar *file)
875 gnutls_x509_crt x509 = NULL;
879 if (is_file_exist(file)) {
880 FILE *fp = g_fopen(file, "r");
882 x509 = gnutls_d2i_X509_fp(fp, 1);
887 log_error(LOG_PROTOCOL, "Can not open certificate file %s\n", file);
892 gnutls_x509_privkey ssl_certificate_get_pkey_from_pem_file(const gchar *file)
894 gnutls_x509_privkey key = NULL;
898 if (is_file_exist(file)) {
899 FILE *fp = g_fopen(file, "r");
901 key = gnutls_d2i_key_fp(fp, 1);
906 log_error(LOG_PROTOCOL, "Can not open key file %s\n", file);
911 /* From GnuTLS lib/gnutls_x509.c */
913 parse_pkcs12 (gnutls_pkcs12_t p12,
914 const char *password,
915 gnutls_x509_privkey * key,
916 gnutls_x509_crt_t * cert)
918 gnutls_pkcs12_bag bag = NULL;
927 ret = gnutls_pkcs12_bag_init (&bag);
934 ret = gnutls_pkcs12_get_bag (p12, index, bag);
935 if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
942 ret = gnutls_pkcs12_bag_get_type (bag, 0);
948 if (ret == GNUTLS_BAG_ENCRYPTED)
950 ret = gnutls_pkcs12_bag_decrypt (bag, password);
957 elements_in_bag = gnutls_pkcs12_bag_get_count (bag);
958 if (elements_in_bag < 0)
963 for (i = 0; i < elements_in_bag; i++)
968 type = gnutls_pkcs12_bag_get_type (bag, i);
974 ret = gnutls_pkcs12_bag_get_data (bag, i, &data);
982 case GNUTLS_BAG_PKCS8_ENCRYPTED_KEY:
983 case GNUTLS_BAG_PKCS8_KEY:
984 ret = gnutls_x509_privkey_init (key);
990 ret = gnutls_x509_privkey_import_pkcs8
991 (*key, &data, GNUTLS_X509_FMT_DER, password,
992 type == GNUTLS_BAG_PKCS8_KEY ? GNUTLS_PKCS_PLAIN : 0);
999 case GNUTLS_BAG_CERTIFICATE:
1000 ret = gnutls_x509_crt_init (cert);
1007 gnutls_x509_crt_import (*cert, &data, GNUTLS_X509_FMT_DER);
1014 case GNUTLS_BAG_ENCRYPTED:
1015 /* XXX Bother to recurse one level down? Unlikely to
1016 use the same password anyway. */
1017 case GNUTLS_BAG_EMPTY:
1024 gnutls_pkcs12_bag_deinit (bag);
1031 gnutls_pkcs12_bag_deinit (bag);
1035 void ssl_certificate_get_x509_and_pkey_from_p12_file(const gchar *file, const gchar *password,
1036 gnutls_x509_crt *x509, gnutls_x509_privkey *pkey)
1038 gnutls_pkcs12_t p12 = NULL;
1047 if (is_file_exist(file)) {
1048 FILE *fp = g_fopen(file, "r");
1050 p12 = gnutls_d2i_PKCS12_fp(fp, 0);
1054 log_error(LOG_PROTOCOL, "Can not open certificate file %s\n", file);
1057 if ((r = parse_pkcs12(p12, password, pkey, x509)) == 0) {
1058 debug_print("got p12\n");
1060 log_error(LOG_PROTOCOL, "%s\n", gnutls_strerror(r));
1062 gnutls_pkcs12_deinit(p12);
1066 #endif /* USE_OPENSSL */