diff options
author | Colin Walters <walters@verbum.org> | 2017-01-09 10:02:19 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2017-01-19 10:47:15 +0000 |
commit | e6952de3d67f8b9896cb15ffa31f50b4e0758714 (patch) | |
tree | 3d03f65a63f37d02cbe4108c5de17243e46eeb30 /src/libostree/ostree-tls-cert-interaction.c | |
parent | b28b785f01b364baac709e87f99fe2ce20c7914e (diff) | |
download | ostree-e6952de3d67f8b9896cb15ffa31f50b4e0758714.tar.gz |
fetcher: Rework API to use strings for tls keys/db
This is prep for the libcurl porting. `GTlsCertificate/GTlsDatabase` are
abstract classes implemented in glib-networking for gnutls. curl's APIs take
file paths as strings, so it's easier to work on both if we move the GLib TLS
bits into the libsoup code.
Closes: #651
Approved by: giuseppe
Diffstat (limited to 'src/libostree/ostree-tls-cert-interaction.c')
-rw-r--r-- | src/libostree/ostree-tls-cert-interaction.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/libostree/ostree-tls-cert-interaction.c b/src/libostree/ostree-tls-cert-interaction.c index 846d5725..7e60f9de 100644 --- a/src/libostree/ostree-tls-cert-interaction.c +++ b/src/libostree/ostree-tls-cert-interaction.c @@ -24,6 +24,8 @@ struct _OstreeTlsCertInteraction { GTlsInteraction parent_instance; + char *cert_path; + char *key_path; GTlsCertificate *cert; }; @@ -44,6 +46,14 @@ request_certificate (GTlsInteraction *interaction, GError **error) { OstreeTlsCertInteraction *self = (OstreeTlsCertInteraction*)interaction; + + if (!self->cert) + { + self->cert = g_tls_certificate_new_from_files (self->cert_path, self->key_path, error); + if (!self->cert) + return G_TLS_INTERACTION_FAILED; + } + g_tls_connection_set_certificate (connection, self->cert); return G_TLS_INTERACTION_HANDLED; } @@ -61,9 +71,11 @@ _ostree_tls_cert_interaction_class_init (OstreeTlsCertInteractionClass *klass) } OstreeTlsCertInteraction * -_ostree_tls_cert_interaction_new (GTlsCertificate *cert) +_ostree_tls_cert_interaction_new (const char *cert_path, + const char *key_path) { OstreeTlsCertInteraction *self = g_object_new (OSTREE_TYPE_TLS_CERT_INTERACTION, NULL); - self->cert = g_object_ref (cert); + self->cert_path = g_strdup (cert_path); + self->key_path = g_strdup (key_path); return self; } |