public sealed override Task Start(TestContext ctx, CancellationToken cancellationToken) { openssl = new NativeOpenSsl(this is IClient, Parameters.EnableDebugging); if (!Parameters.VerifyPeerCertificate) { openssl.SetCertificateVerify(NativeOpenSsl.VerifyMode.SSL_VERIFY_NONE, null); } else { NativeOpenSsl.VerifyMode mode = NativeOpenSsl.VerifyMode.SSL_VERIFY_PEER; var serverParams = Parameters as IServerParameters; if (serverParams != null) { if (serverParams.RequireClientCertificate) { mode |= NativeOpenSsl.VerifyMode.SSL_VERIFY_FAIL_IF_NO_PEER_CERT; } else if (serverParams.AskForClientCertificate) { mode |= NativeOpenSsl.VerifyMode.SSL_VERIFY_CLIENT_ONCE; } } openssl.SetCertificateVerify(mode, RemoteValidationCallback); } Initialize(); return(FinishedTask); }
protected override void Stop() { if (openssl != null) { openssl.Dispose(); openssl = null; } }