)
Constructs a new secure client socket and connect it to the given host on the given port. The returned Future is completed with the RawSecureSocket when it is connected and ready for subscription.
The certificate provided by the server is checked using the certificate
database provided in SecureSocket.initialize, and/or the default built-in
root certificates. If sendClientCertificate
is
set to true, the socket will send a client certificate if one is
requested by the server. If certificateName
is the nickname of
a certificate in the certificate database, that certificate will be sent.
If certificateName
is null, which is the usual use case, an
appropriate certificate will be searched for in the database and
sent automatically, based on what the server says it will accept.
onBadCertificate
is an optional handler for unverifiable certificates.
The handler receives the X509Certificate, and can inspect it and
decide (or let the user decide) whether to accept
the connection or not. The handler should return true
to continue the RawSecureSocket connection.
Source
/**
* Constructs a new secure client socket and connect it to the given
* host on the given port. The returned Future is completed with the
* RawSecureSocket when it is connected and ready for subscription.
*
* The certificate provided by the server is checked using the certificate
* database provided in [SecureSocket.initialize], and/or the default built-in
* root certificates. If [sendClientCertificate] is
* set to true, the socket will send a client certificate if one is
* requested by the server. If [certificateName] is the nickname of
* a certificate in the certificate database, that certificate will be sent.
* If [certificateName] is null, which is the usual use case, an
* appropriate certificate will be searched for in the database and
* sent automatically, based on what the server says it will accept.
*
* [onBadCertificate] is an optional handler for unverifiable certificates.
* The handler receives the [X509Certificate], and can inspect it and
* decide (or let the user decide) whether to accept
* the connection or not. The handler should return true
* to continue the [RawSecureSocket] connection.
*/
static Future<RawSecureSocket> connect(
host,
int port,
{bool sendClientCertificate: false,
String certificateName,
bool onBadCertificate(X509Certificate certificate),
List<String> supportedProtocols}) {
_RawSecureSocket._verifyFields(
host,
port,
certificateName,
false,
false,
false,
sendClientCertificate,
onBadCertificate);
return RawSocket.connect(host, port)
.then((socket) {
return secure(socket,
sendClientCertificate: sendClientCertificate,
certificateName: certificateName,
onBadCertificate: onBadCertificate,
supportedProtocols: supportedProtocols);
});
}