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
This commit is contained in:
1 parent
b28b785f01
commit
e6952de3d6
5 files changed
+61
-49
No files matched your search
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user