public NativeOpenSsl(bool isServer, bool debug, NativeOpenSslProtocol protocol) { this.isServer = isServer; this.enableDebugging = debug; this.protocol = protocol; readHandler = Read_internal; writeHandler = Write_internal; shutdownHandler = Shutdown_internal; if (debug) { debug_callback = new DebugCallback(OnDebugCallback); } message_callback = new MessageCallback(OnMessageCallback); handle = native_openssl_initialize(debug ? 1 : 0, protocol, debug_callback, message_callback); if (handle.IsInvalid) { throw new InvalidOperationException("Handle invalid."); } var ret = native_openssl_create_context(handle, !isServer); CheckError(ret); }
public NativeOpenSsl(bool isClient, bool debug) { this.isClient = isClient; this.enableDebugging = debug; if (debug) { debug_callback = new DebugCallback(OnDebugCallback); } message_callback = new MessageCallback(OnMessageCallback); handle = native_openssl_initialize(debug ? 1 : 0, debug_callback, message_callback); if (handle.IsInvalid) { throw new ConnectionException("Handle invalid."); } var ret = native_openssl_create_context(handle, isClient); CheckError(ret); }
protected override void Dispose(bool disposing) { if (disposing) { if (certificate != null) { certificate.Dispose(); certificate = null; } if (privateKey != null) { privateKey.Dispose(); privateKey = null; } if (handle != null) { handle.Dispose(); handle = null; } } base.Dispose(disposing); }
extern static int native_openssl_load_certificate_from_pkcs12 ( OpenSslHandle handle, byte[] buffer, int len, [MarshalAs (UnmanagedType.LPStr)] string password, int passlen, out CertificateHandle certificate, out PrivateKeyHandle privateKey);
extern static CertificateHandle native_openssl_load_certificate_from_pem (OpenSslHandle handle, byte[] buffer, int len);
extern static int native_openssl_accept (OpenSslHandle handle);
extern static int native_openssl_connect (OpenSslHandle handle, byte[] ip, int port);
extern static int native_openssl_create_connection (OpenSslHandle handle);
extern static int native_openssl_set_named_curve (OpenSslHandle handle, string curve_name);
public NativeOpenSsl (bool isServer, bool debug, NativeOpenSslProtocol protocol) { this.isServer = isServer; this.enableDebugging = debug; this.protocol = protocol; readHandler = Read_internal; writeHandler = Write_internal; shutdownHandler = Shutdown_internal; if (debug) debug_callback = new DebugCallback (OnDebugCallback); message_callback = new MessageCallback (OnMessageCallback); handle = native_openssl_initialize (debug ? 1 : 0, protocol, debug_callback, message_callback); if (handle.IsInvalid) throw new ConnectionException ("Handle invalid."); var ret = native_openssl_create_context (handle, !isServer); CheckError (ret); }
extern static int native_openssl_accept(OpenSslHandle handle);
extern static int native_openssl_bind(OpenSslHandle handle, byte[] ip, int port);
extern static int native_openssl_connect(OpenSslHandle handle, byte[] ip, int port);
extern static int native_openssl_close(OpenSslHandle handle);
extern static int native_openssl_create_connection(OpenSslHandle handle);
extern static int native_openssl_create_context(OpenSslHandle handle, bool client);
extern static void native_openssl_set_certificate_verify (OpenSslHandle handle, int mode, VerifyCallback verify_cb, CertificateVerifyCallback cert_cb, int depth);
extern static short native_openssl_get_current_cipher (OpenSslHandle handle);
extern static int native_openssl_read(OpenSslHandle handle, byte[] buffer, int offset, int size);
extern static int native_openssl_set_named_curve(OpenSslHandle handle, string curve_name);
extern static CertificateHandle native_openssl_load_certificate_from_pem(OpenSslHandle handle, byte[] buffer, int len);
extern static int native_openssl_create_context (OpenSslHandle handle, bool client);
extern static PrivateKeyHandle native_openssl_load_private_key_from_pem(OpenSslHandle handle, byte[] buffer, int len);
extern static int native_openssl_close (OpenSslHandle handle);
extern static int native_openssl_load_certificate_from_pkcs12( OpenSslHandle handle, byte[] buffer, int len, [MarshalAs(UnmanagedType.LPStr)] string password, int passlen, out CertificateHandle certificate, out PrivateKeyHandle privateKey);
extern static int native_openssl_bind (OpenSslHandle handle, byte[] ip, int port);
extern static int native_openssl_set_certificate( OpenSslHandle handle, CertificateHandle certificate, PrivateKeyHandle privateKey);
extern static int native_openssl_read (OpenSslHandle handle, byte[] buffer, int offset, int size);
extern static void native_openssl_set_certificate_verify(OpenSslHandle handle, int mode, VerifyCallback verify_cb, CertificateVerifyCallback cert_cb, int depth);
extern static PrivateKeyHandle native_openssl_load_private_key_from_pem (OpenSslHandle handle, byte[] buffer, int len);
extern static int native_openssl_shutdown(OpenSslHandle handle);
extern static int native_openssl_set_certificate ( OpenSslHandle handle, CertificateHandle certificate, PrivateKeyHandle privateKey);
extern static short native_openssl_get_current_cipher(OpenSslHandle handle);
extern static int native_openssl_shutdown (OpenSslHandle handle);
extern static int native_openssl_set_cipher_list(OpenSslHandle handle, byte[] ciphers, int count);
extern static int native_openssl_set_cipher_list (OpenSslHandle handle, byte[] ciphers, int count);
extern static int native_openssl_set_dh_params (OpenSslHandle handle, byte[] p, int p_len, byte[] g, int b_len);
protected override void Dispose (bool disposing) { if (disposing) { if (certificate != null) { certificate.Dispose (); certificate = null; } if (privateKey != null) { privateKey.Dispose (); privateKey = null; } if (handle != null) { native_openssl_close (handle); handle.Dispose (); handle = null; } } base.Dispose (disposing); }
extern static int native_openssl_set_dh_params(OpenSslHandle handle, byte[] p, int p_len, byte[] g, int b_len);