Display TLS certificate in the GUI



Hello list,

in a Gnome Shell extension I want to connect with libsoup to a https://
URI which has a self-signed certificate.
My intention is to let the extension display the certificate to the user
and let the user decide whether to trust the certificate.

My current approach is this

======================================================================
const Lang = imports.lang;
const Gcr = imports.gi.Gcr;
const GcrUi = imports.gi.GcrUi;
const Soup = imports.gi.Soup;

const _session = new Soup.Session();

// ...

const SyncthingMenu = new Lang.Class({

    _received: function(session, msg) {
        if (msg.status_code === Soup.Status.SSL_FAILED) {
            let cert = msg.tls_certificate.certificate;
            let certificate = Gcr.SimpleCertificate.new(cert);
            let widget = GcrUi.CertificateWidget();
            widget.certificate = certificate;
            // ...
        }
    },

    _run: function() {
        let uri = 'https://localhost/';
        let msg = Soup.Message.new('GET', uri);
        _session.queue_message(msg, Lang.bind(this, this._received));
    },
}
======================================================================


However, the line
let cert = msg.tls_certificate.certificate;
ist not exectuted. It prints an error message:

======================================================================
(gnome-shell:543): Gjs-WARNING **: JS ERROR: Error: Unable to introspect
element-type of container in GValue
======================================================================


Can someone help me understand this error message?
Has someone a suggestion for a better solution?


Thank you and kind regards
Jay


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]