public Task AuthenticateAsClient(X509Certificate2 certificate) { var ssl = new SslStream(Stream, false, (sender, x509Certificate, chain, errors) => { if (errors.HasFlag(SslPolicyErrors.RemoteCertificateNameMismatch)) { return true; } // if (errors == SslPolicyErrors.None) //return true; return true; }, null); var tempStream = new SslStreamWrapper(ssl); Stream = tempStream; Func<AsyncCallback, object, IAsyncResult> begin = (cb, s) => ssl.BeginAuthenticateAsClient(this.RemoteIpAddress, new X509Certificate2Collection(certificate),SslProtocols.Tls, false, cb, s); var task = Task.Factory.FromAsync(begin, ssl.EndAuthenticateAsClient, null); return task; }
public Task AuthenticateAsClient() { var ssl = new SslStream(Stream, false, (sender, x509Certificate, chain, errors) => { if (errors == SslPolicyErrors.None) return true; return false; }, null); var tempStream = new SslStreamWrapper(ssl); Stream = tempStream; Func<AsyncCallback, object, IAsyncResult> begin = (cb, s) => ssl.BeginAuthenticateAsClient(this._uri.Host, cb, s); var task = Task.Factory.FromAsync(begin, ssl.EndAuthenticateAsClient, null); return task; }
public Task AuthenticateAsClient() { var ssl = new SslStream(Stream, false, (sender, x509Certificate, chain, errors) => { if (errors == SslPolicyErrors.None) { return(true); } return(false); }, null); var tempStream = new SslStreamWrapper(ssl); Stream = tempStream; Func <AsyncCallback, object, IAsyncResult> begin = (cb, s) => ssl.BeginAuthenticateAsClient(this._uri.Host, cb, s); var task = Task.Factory.FromAsync(begin, ssl.EndAuthenticateAsClient, null); return(task); }