#include "socket.h"
#include "hooks.h"
#include "defs.h"
-#include "claws_io.h"
+#include "file-utils.h"
static GHashTable *warned_expired = NULL;
static gchar *get_certificate_path(const gchar *host, const gchar *port, const gchar *fp)
{
- if (fp != NULL && prefs_common_unsafe_ssl_certs())
- return g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
- "certs", G_DIR_SEPARATOR_S,
- host, ".", port, ".", fp, ".cert", NULL);
- else
- return g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
- "certs", G_DIR_SEPARATOR_S,
- host, ".", port, ".cert", NULL);
+ gchar *ret;
+ gchar *filename;
+
+ if (fp != NULL && prefs_common_unsafe_ssl_certs()) {
+ filename = g_strconcat(host, ".", port, ".", fp, ".cert", NULL);
+ } else {
+ filename = g_strconcat(host, ".", port, ".cert", NULL);
+ }
+ subst_for_filename(filename);
+
+ ret = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
+ "certs", G_DIR_SEPARATOR_S,
+ filename, NULL);
+
+ g_free(filename);
+ return ret;
}
static gchar *get_certificate_chain_path(const gchar *host, const gchar *port, const gchar *fp)
int r;
if ((r = gnutls_x509_crt_export(x509_cert, format, output, &cert_size)) < 0) {
- g_warning("couldn't export cert %s (%zd)", gnutls_strerror(r), cert_size);
+ g_warning("couldn't export cert %s (%"G_GSIZE_FORMAT")", gnutls_strerror(r), cert_size);
return;
}
-
+#ifdef G_OS_WIN32
+ debug_print("writing %Iu bytes\n",cert_size);
+#else
debug_print("writing %zd bytes\n",cert_size);
+#endif
if (claws_fwrite(&output, 1, cert_size, fp) < cert_size) {
g_warning("failed to write cert: %d %s", errno, g_strerror(errno));
}
*output = malloc(cert_size);
if ((r = gnutls_x509_crt_export(x509_cert, GNUTLS_X509_FMT_DER, *output, &cert_size)) < 0) {
- g_warning("couldn't export cert %s (%zd)", gnutls_strerror(r), cert_size);
+ g_warning("couldn't export cert %s (%"G_GSIZE_FORMAT")", gnutls_strerror(r), cert_size);
free(*output);
*output = NULL;
return 0;
*output = malloc(key_size);
if ((r = gnutls_x509_privkey_export(pkey, GNUTLS_X509_FMT_DER, *output, &key_size)) < 0) {
- g_warning("couldn't export key %s (%zd)", gnutls_strerror(r), key_size);
+ g_warning("couldn't export key %s (%"G_GSIZE_FORMAT")", gnutls_strerror(r), key_size);
free(*output);
*output = NULL;
return 0;
return FALSE;
}
if (cert_size_a != cert_size_b) {
- g_warning("size differ %zd %zd", cert_size_a, cert_size_b);
+ g_warning("size differ %"G_GSIZE_FORMAT" %"G_GSIZE_FORMAT, cert_size_a, cert_size_b);
g_free(output_a);
g_free(output_b);
return FALSE;