diff options
| -rw-r--r-- | src/userpref.c | 24 | ||||
| -rw-r--r-- | src/userpref.h | 1 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/userpref.c b/src/userpref.c index 10c14a0..09ec495 100644 --- a/src/userpref.c +++ b/src/userpref.c | |||
| @@ -212,6 +212,30 @@ userpref_error_t userpref_set_device_public_key(const char *uuid, gnutls_datum_t | |||
| 212 | return USERPREF_E_SUCCESS; | 212 | return USERPREF_E_SUCCESS; |
| 213 | } | 213 | } |
| 214 | 214 | ||
| 215 | /** Remove the public key stored for the device with uuid from this host. | ||
| 216 | * | ||
| 217 | * @param uuid The uuid of the device | ||
| 218 | * | ||
| 219 | * @return USERPREF_E_SUCCESS on success. | ||
| 220 | */ | ||
| 221 | userpref_error_t userpref_remove_device_public_key(const char *uuid) | ||
| 222 | { | ||
| 223 | if (!userpref_has_device_public_key(uuid)) | ||
| 224 | return USERPREF_E_SUCCESS; | ||
| 225 | |||
| 226 | /* build file path */ | ||
| 227 | gchar *device_file = g_strconcat(uuid, ".pem", NULL); | ||
| 228 | gchar *pem = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, device_file, NULL); | ||
| 229 | |||
| 230 | /* remove file */ | ||
| 231 | g_remove(pem); | ||
| 232 | |||
| 233 | g_free(pem); | ||
| 234 | g_free(device_file); | ||
| 235 | |||
| 236 | return USERPREF_E_SUCCESS; | ||
| 237 | } | ||
| 238 | |||
| 215 | /** Private function which reads the given file into a gnutls structure. | 239 | /** Private function which reads the given file into a gnutls structure. |
| 216 | * | 240 | * |
| 217 | * @param file The filename of the file to read | 241 | * @param file The filename of the file to read |
diff --git a/src/userpref.h b/src/userpref.h index 3540468..48b8969 100644 --- a/src/userpref.h +++ b/src/userpref.h | |||
| @@ -38,6 +38,7 @@ G_GNUC_INTERNAL userpref_error_t userpref_get_keys_and_certs(gnutls_x509_privkey | |||
| 38 | G_GNUC_INTERNAL userpref_error_t userpref_set_keys_and_certs(gnutls_datum_t * root_key, gnutls_datum_t * root_cert, gnutls_datum_t * host_key, gnutls_datum_t * host_cert); | 38 | G_GNUC_INTERNAL userpref_error_t userpref_set_keys_and_certs(gnutls_datum_t * root_key, gnutls_datum_t * root_cert, gnutls_datum_t * host_key, gnutls_datum_t * host_cert); |
| 39 | G_GNUC_INTERNAL userpref_error_t userpref_get_certs_as_pem(gnutls_datum_t *pem_root_cert, gnutls_datum_t *pem_host_cert); | 39 | G_GNUC_INTERNAL userpref_error_t userpref_get_certs_as_pem(gnutls_datum_t *pem_root_cert, gnutls_datum_t *pem_host_cert); |
| 40 | G_GNUC_INTERNAL userpref_error_t userpref_set_device_public_key(const char *uuid, gnutls_datum_t public_key); | 40 | G_GNUC_INTERNAL userpref_error_t userpref_set_device_public_key(const char *uuid, gnutls_datum_t public_key); |
| 41 | G_GNUC_INTERNAL userpref_error_t userpref_remove_device_public_key(const char *uuid); | ||
| 41 | G_GNUC_INTERNAL int userpref_has_device_public_key(const char *uuid); | 42 | G_GNUC_INTERNAL int userpref_has_device_public_key(const char *uuid); |
| 42 | G_GNUC_INTERNAL void userpref_get_host_id(char **host_id); | 43 | G_GNUC_INTERNAL void userpref_get_host_id(char **host_id); |
| 43 | 44 | ||
