Gio.TlsConnection::accept-certificate
connect('accept-certificate', function (tlsConnection, peer_cert: Gio.TlsCertificate, errors: Gio.TlsCertificateFlags, ): Boolean);
Emitted during the TLS handshake after the peer certificate has been received. You can examine peer_cert's certification path by calling Gio.TlsCertificate.prototype.get_issuer on it.
For a client-side connection, peer_cert is the server's certificate, and the signal will only be emitted if the certificate was not acceptable according to @conn's #GTlsClientConnection:validation_flags. If you would like the certificate to be accepted despite errors, return true from the signal handler. Otherwise, if no handler accepts the certificate, the handshake will fail with Gio.TlsError.bad_certificate.
For a server-side connection, peer_cert is the certificate presented by the client, if this was requested via the server's #GTlsServerConnection:authentication_mode. On the server side, the signal is always emitted when the client presents a certificate, and the certificate will only be accepted if a handler returns true.
Note that if this signal is emitted as part of asynchronous I/O in the main thread, then you should not attempt to interact with the user before returning from the signal handler. If you want to let the user decide whether or not to accept the certificate, you would have to return false from the signal handler on the first attempt, and then after the connection attempt returns a Gio.TlsError.handshake, you can interact with the user, and if the user decides to accept the certificate, remember that fact, create a new connection, and return true from the signal handler the next time.
If you are doing I/O in another thread, you do not need to worry about this, and can simply block in the signal handler until the UI thread returns an answer.
Since 2.28
- tlsConnection
instance of Gio.TlsConnection that is emitting the signal
- peer_cert
the peer's Gio.TlsCertificate
- errors
the problems with peer_cert.
- Returns
true to accept peer_cert (which will also immediately end the signal emission). false to allow the signal emission to continue, which will cause the handshake to fail if no one else overrides it.