2020-11-16 14:55:33 +00:00
|
|
|
public abstract class Xmpp.TlsXmppStream : IoXmppStream {
|
|
|
|
|
|
|
|
public TlsCertificateFlags? errors;
|
|
|
|
|
2020-12-31 18:00:54 +00:00
|
|
|
public delegate bool OnInvalidCert(GLib.TlsConnection conn, GLib.TlsCertificate peer_cert, GLib.TlsCertificateFlags errors);
|
|
|
|
|
|
|
|
protected TlsXmppStream(Jid remote_name) {
|
|
|
|
base(remote_name);
|
|
|
|
}
|
|
|
|
|
2020-11-16 14:55:33 +00:00
|
|
|
protected bool on_invalid_certificate(TlsCertificate peer_cert, TlsCertificateFlags errors) {
|
|
|
|
this.errors = errors;
|
|
|
|
|
|
|
|
string error_str = "";
|
|
|
|
foreach (var f in new TlsCertificateFlags[]{TlsCertificateFlags.UNKNOWN_CA, TlsCertificateFlags.BAD_IDENTITY,
|
|
|
|
TlsCertificateFlags.NOT_ACTIVATED, TlsCertificateFlags.EXPIRED, TlsCertificateFlags.REVOKED,
|
|
|
|
TlsCertificateFlags.INSECURE, TlsCertificateFlags.GENERIC_ERROR, TlsCertificateFlags.VALIDATE_ALL}) {
|
|
|
|
if (f in errors) {
|
|
|
|
error_str += @"$(f), ";
|
|
|
|
}
|
|
|
|
}
|
2020-12-31 18:00:54 +00:00
|
|
|
warning(@"[%p, %s] Tls Certificate Errors: %s", this, this.remote_name, error_str);
|
2020-11-16 14:55:33 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|