}
#ifdef USE_GNUTLS
-static void gnutls_i2d_X509_fp(FILE *fp, gnutls_x509_crt_t x509_cert)
+static void gnutls_export_X509_fp(FILE *fp, gnutls_x509_crt_t x509_cert, gnutls_x509_crt_fmt_t format)
{
char output[10*1024];
size_t cert_size = 10*1024;
int r;
- if ((r = gnutls_x509_crt_export(x509_cert, GNUTLS_X509_FMT_DER, output, &cert_size)) < 0) {
+ if ((r = gnutls_x509_crt_export(x509_cert, format, output, &cert_size)) < 0) {
g_warning("couldn't export cert %s (%zd)\n", gnutls_strerror(r), cert_size);
return;
}
return key_size;
}
-static int gnutls_d2i_X509_list_fp(FILE *fp, gnutls_x509_crt_fmt_t format,
+static int gnutls_import_X509_list_fp(FILE *fp, gnutls_x509_crt_fmt_t format,
gnutls_x509_crt_t **cert_list, gint *num_certs)
{
gnutls_x509_crt_t *crt_list;
}
/* return one certificate, read from file */
-static gnutls_x509_crt_t gnutls_d2i_X509_fp(FILE *fp, gnutls_x509_crt_fmt_t format)
+static gnutls_x509_crt_t gnutls_import_X509_fp(FILE *fp, gnutls_x509_crt_fmt_t format)
{
gnutls_x509_crt_t *certs = NULL;
gnutls_x509_crt_t cert = NULL;
int i, ncerts, r;
- if ((r = gnutls_d2i_X509_list_fp(fp, format, &certs, &ncerts)) < 0) {
+ if ((r = gnutls_import_X509_list_fp(fp, format, &certs, &ncerts)) < 0) {
return NULL;
}
return cert;
}
-static gnutls_x509_privkey_t gnutls_d2i_key_fp(FILE *fp, gnutls_x509_crt_fmt_t format)
+static gnutls_x509_privkey_t gnutls_import_key_fp(FILE *fp, gnutls_x509_crt_fmt_t format)
{
gnutls_x509_privkey_t key = NULL;
gnutls_datum_t tmp;
return key;
}
-static gnutls_pkcs12_t gnutls_d2i_PKCS12_fp(FILE *fp, gnutls_x509_crt_fmt_t format)
+static gnutls_pkcs12_t gnutls_import_PKCS12_fp(FILE *fp, gnutls_x509_crt_fmt_t format)
{
gnutls_pkcs12_t p12 = NULL;
gnutls_datum_t tmp;
return;
}
- gnutls_i2d_X509_fp(fp, cert->x509_cert);
+ gnutls_export_X509_fp(fp, cert->x509_cert, GNUTLS_X509_FMT_DER);
g_free(file);
fclose(fp);
return NULL;
}
- if ((tmp_x509 = gnutls_d2i_X509_fp(fp, GNUTLS_X509_FMT_DER)) != NULL) {
+ if ((tmp_x509 = gnutls_import_X509_fp(fp, GNUTLS_X509_FMT_DER)) != NULL) {
cert = ssl_certificate_new(tmp_x509, host, port);
debug_print("got cert %p\n", cert);
gnutls_x509_crt_deinit(tmp_x509);
else
return (guint)-1;
- if ((r = gnutls_d2i_X509_list_fp(fp, GNUTLS_X509_FMT_PEM, &ca_list, &max)) < 0) {
+ if ((r = gnutls_import_X509_list_fp(fp, GNUTLS_X509_FMT_PEM, &ca_list, &max)) < 0) {
debug_print("cert import failed: %s\n", gnutls_strerror(r));
fclose(fp);
return (guint)-1;
int r = -errno;
if (fp) {
- r = gnutls_d2i_X509_list_fp(fp, GNUTLS_X509_FMT_PEM, &cas, &ncas);
+ r = gnutls_import_X509_list_fp(fp, GNUTLS_X509_FMT_PEM, &cas, &ncas);
fclose(fp);
}
if (is_file_exist(file)) {
FILE *fp = g_fopen(file, "r");
if (fp) {
- x509 = gnutls_d2i_X509_fp(fp, GNUTLS_X509_FMT_PEM);
+ x509 = gnutls_import_X509_fp(fp, GNUTLS_X509_FMT_PEM);
fclose(fp);
return x509;
} else {
if (is_file_exist(file)) {
FILE *fp = g_fopen(file, "r");
if (fp) {
- key = gnutls_d2i_key_fp(fp, GNUTLS_X509_FMT_PEM);
+ key = gnutls_import_key_fp(fp, GNUTLS_X509_FMT_PEM);
fclose(fp);
return key;
} else {
if (is_file_exist(file)) {
FILE *fp = g_fopen(file, "r");
if (fp) {
- p12 = gnutls_d2i_PKCS12_fp(fp, GNUTLS_X509_FMT_DER);
+ p12 = gnutls_import_PKCS12_fp(fp, GNUTLS_X509_FMT_DER);
fclose(fp);
if (!p12) {
log_error(LOG_PROTOCOL, _("Failed to read P12 certificate file %s\n"), file);