feat(moxxmpp_socket_tcp): Make onBadCertificate available
This commit is contained in:
parent
d5493a185a
commit
608ba8ce4a
@ -49,12 +49,13 @@ class TCPSocketWrapper extends BaseSocketWrapper {
|
|||||||
Future<List<MoxSrvRecord>> srvQuery(String domain, bool dnssec) async {
|
Future<List<MoxSrvRecord>> srvQuery(String domain, bool dnssec) async {
|
||||||
return <MoxSrvRecord>[];
|
return <MoxSrvRecord>[];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _onBadCertificate(dynamic certificate, String domain) {
|
/// Called when we encounter a certificate we cannot verify. [certificate] refers to the certificate
|
||||||
_log.fine('Bad certificate: ${certificate.toString()}');
|
/// in question, while [domain] refers to the domain we try to validate the certificate against.
|
||||||
//final isExpired = certificate.endValidity.isAfter(DateTime.now());
|
///
|
||||||
// TODO(Unknown): Either validate the certificate ourselves or use a platform native
|
/// Return true if the certificate should be accepted. Return false if it should be rejected.
|
||||||
// hostname verifier (or Dart adds it themselves)
|
@visibleForOverriding
|
||||||
|
bool onBadCertificate(dynamic certificate, String domain) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +84,7 @@ class TCPSocketWrapper extends BaseSocketWrapper {
|
|||||||
sock,
|
sock,
|
||||||
host: domain,
|
host: domain,
|
||||||
supportedProtocols: const [ xmppClientALPNId ],
|
supportedProtocols: const [ xmppClientALPNId ],
|
||||||
onBadCertificate: (cert) => _onBadCertificate(cert, domain),
|
onBadCertificate: (cert) => onBadCertificate(cert, domain),
|
||||||
);
|
);
|
||||||
|
|
||||||
_ignoreSocketClosure = false;
|
_ignoreSocketClosure = false;
|
||||||
@ -175,7 +176,7 @@ class TCPSocketWrapper extends BaseSocketWrapper {
|
|||||||
_socket = await SecureSocket.secure(
|
_socket = await SecureSocket.secure(
|
||||||
_socket!,
|
_socket!,
|
||||||
supportedProtocols: const [ xmppClientALPNId ],
|
supportedProtocols: const [ xmppClientALPNId ],
|
||||||
onBadCertificate: (cert) => _onBadCertificate(cert, domain),
|
onBadCertificate: (cert) => onBadCertificate(cert, domain),
|
||||||
);
|
);
|
||||||
|
|
||||||
_secure = true;
|
_secure = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user