private static IntPtr GetMethodFromProtocol(OpenSslProtocol protocol, bool server) { IntPtr method = IntPtr.Zero; switch (protocol) { case OpenSslProtocol.AutoDetect: if (server) { method = OpenSslNative.SSLv23_server_method(); } else { method = OpenSslNative.SSLv23_client_method(); } break; case OpenSslProtocol.SSLv2: if (server) { method = OpenSslNative.SSLv2_server_method(); } else { method = OpenSslNative.SSLv2_client_method(); } break; case OpenSslProtocol.SSLv3: if (server) { method = OpenSslNative.SSLv3_server_method(); } else { method = OpenSslNative.SSLv3_client_method(); } break; case OpenSslProtocol.TLSv1: if (server) { method = OpenSslNative.TLSv1_server_method(); } else { method = OpenSslNative.TLSv1_client_method(); } break; default: break; } return(OpenSslUtility.AssertNotNull(method)); }
public OpenSslPrivateKey(OpenSslBIO bio) { _pkey = OpenSslUtility.AssertNotNull(OpenSslNative.PEM_read_bio_PrivateKey(bio.Handle, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero)); }
public static OpenSslBIO FromFile(string file) { return(new OpenSslBIO(OpenSslUtility.AssertNotNull(OpenSslNative.BIO_new_file(file, "r")))); }
public OpenSslCertificate(OpenSslBIO bio) { _x509 = OpenSslUtility.AssertNotNull(OpenSslNative.PEM_read_bio_X509(bio.Handle, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero)); }
private void InitializeSocket(Socket socket) { OpenSslUtility.AssertSuccess(OpenSslNative.SSL_set_fd(_ssl, socket.Handle.ToInt32())); _socket = socket; }
public void Connect(Socket socket) { InitializeSocket(socket); OpenSslUtility.AssertSuccess(OpenSslNative.SSL_connect(_ssl)); }
public OpenSslConnection(OpenSslContext ctx) { _context = ctx; _ssl = OpenSslUtility.AssertNotNull(OpenSslNative.SSL_new(_context.Handle)); }
public OpenSslContext(OpenSslProtocol protocol, bool server) { _ctx = OpenSslUtility.AssertNotNull(OpenSslNative.SSL_CTX_new(GetMethodFromProtocol(protocol, server))); }