javascriptsslcertificategjscacerts

proper use of SSL certificate with Soup in javascript


I would like to ask how to properly use Soup in gnome-shell extension with a certificate on the client site.

The snippet of my code looks like this:

const Soup = imports.gi.Soup;
const GObject = imports.gi.GObject;
const Gio = imports.gi.Gio;

const TlsDatabase = GObject.registerClass({
    Implements: [Gio.TlsFileDatabase],
    Properties: {
        'anchors': GObject.ParamSpec.override('anchors', Gio.TlsFileDatabase),
    },
}, class TlsDatabase extends Gio.TlsDatabase {});


let session = Soup.Session.new();
session.ssl_strict = true;
session.tls_database = new TlsDatabase({anchors: "path.pem"});;

Edited:

Thank you for any help.


Solution

  • You might have to implement vfunc_verify_chain() in your class. (It's not clear to me whether Gio.TlsDatabase provides no default implementation of this virtual function, or it does and this is a bug.)