Skip to content

Commit

Permalink
refactor(bluez): include TLS certificate in identity packet
Browse files Browse the repository at this point in the history
  • Loading branch information
andyholmes committed Sep 25, 2023
1 parent b06aa03 commit 9bf6027
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/plugins/bluez/valent-bluez-channel-service.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,35 @@ on_name_owner_changed (GDBusProxy *proxy,
/*
* ValentChannelService
*/
static void
valent_bluez_channel_service_build_identity (ValentChannelService *service)
{
ValentChannelServiceClass *klass;
g_autoptr (JsonNode) identity = NULL;

g_assert (VALENT_IS_BLUEZ_CHANNEL_SERVICE (service));

/* Chain-up */
klass = VALENT_CHANNEL_SERVICE_CLASS (valent_bluez_channel_service_parent_class);
klass->build_identity (service);

/* Set the certificate on the packet */
identity = valent_channel_service_ref_identity (service);

if (identity != NULL)
{
g_autoptr (GTlsCertificate) certificate = NULL;
g_autofree char *certificate_pem = NULL;
JsonObject *body;

certificate = valent_channel_service_ref_certificate (service);
g_object_get (certificate, "certificate-pem", &certificate_pem, NULL);

body = valent_packet_get_body (identity);
json_object_set_string_member (body, "certificate", certificate_pem);
}
}

static void
valent_bluez_channel_service_identify (ValentChannelService *service,
const char *target)
Expand Down Expand Up @@ -502,6 +531,7 @@ valent_bluez_channel_service_class_init (ValentBluezChannelServiceClass *klass)

vobject_class->destroy = valent_bluez_channel_service_destroy;

service_class->build_identity = valent_bluez_channel_service_build_identity;
service_class->identify = valent_bluez_channel_service_identify;
}

Expand Down

0 comments on commit 9bf6027

Please sign in to comment.