From 6f59d691a2860180dddcffebdc46368ef35ace6c Mon Sep 17 00:00:00 2001 From: Anthony Tong Date: Fri, 28 Oct 2011 11:38:45 -0400 Subject: [PATCH] certstore: update verified certificates, be graceful on filesystem errors --- libfreerdp-core/tls.c | 2 ++ libfreerdp-utils/certstore.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/libfreerdp-core/tls.c b/libfreerdp-core/tls.c index 988eeab9f..6aea9f6a0 100644 --- a/libfreerdp-core/tls.c +++ b/libfreerdp-core/tls.c @@ -277,6 +277,8 @@ int tls_verify_certificate(CryptoCert cert, rdpSettings* settings, char* hostnam if(!accept_certificate) return 1; + + cert_data_print(certstore); } else if (certstore->match == -1) { diff --git a/libfreerdp-utils/certstore.c b/libfreerdp-utils/certstore.c index 1413351f7..1442b6939 100644 --- a/libfreerdp-utils/certstore.c +++ b/libfreerdp-utils/certstore.c @@ -180,6 +180,9 @@ int cert_data_match(rdpCertStore* certstore) fp = certstore->fp; cert_data = certstore->certdata; + if (!fp) + return certstore->match; + fseek(fp, 0, SEEK_END); size = ftell(fp); fseek(fp, 0, SEEK_SET); @@ -223,6 +226,14 @@ int cert_data_match(rdpCertStore* certstore) void cert_data_print(rdpCertStore* certstore) { - fseek(certstore->fp, 0, SEEK_END); + FILE* fp; + + /* reopen in append mode */ + fp = fopen(certstore->file, "a"); + + if (!fp) + return; + fprintf(certstore->fp,"%s %s\n", certstore->certdata->hostname, certstore->certdata->fingerprint); + fclose(fp); }