Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
 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);
 }
Example #4
0
		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);
Example #5
0
		extern static CertificateHandle native_openssl_load_certificate_from_pem (OpenSslHandle handle, byte[] buffer, int len);
Example #6
0
		extern static int native_openssl_accept (OpenSslHandle handle);
Example #7
0
		extern static int native_openssl_connect (OpenSslHandle handle, byte[] ip, int port);
Example #8
0
		extern static int native_openssl_create_connection (OpenSslHandle handle);
Example #9
0
		extern static int native_openssl_set_named_curve (OpenSslHandle handle, string curve_name);
Example #10
0
		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);
		}
Example #11
0
 extern static int native_openssl_accept(OpenSslHandle handle);
Example #12
0
 extern static int native_openssl_bind(OpenSslHandle handle, byte[] ip, int port);
Example #13
0
 extern static int native_openssl_connect(OpenSslHandle handle, byte[] ip, int port);
Example #14
0
 extern static int native_openssl_close(OpenSslHandle handle);
Example #15
0
 extern static int native_openssl_create_connection(OpenSslHandle handle);
Example #16
0
 extern static int native_openssl_create_context(OpenSslHandle handle, bool client);
Example #17
0
		extern static void native_openssl_set_certificate_verify (OpenSslHandle handle, int mode, VerifyCallback verify_cb, CertificateVerifyCallback cert_cb, int depth);
Example #18
0
		extern static short native_openssl_get_current_cipher (OpenSslHandle handle);
Example #19
0
 extern static int native_openssl_read(OpenSslHandle handle, byte[] buffer, int offset, int size);
Example #20
0
 extern static int native_openssl_set_named_curve(OpenSslHandle handle, string curve_name);
Example #21
0
 extern static CertificateHandle native_openssl_load_certificate_from_pem(OpenSslHandle handle, byte[] buffer, int len);
Example #22
0
		extern static int native_openssl_create_context (OpenSslHandle handle, bool client);
Example #23
0
 extern static PrivateKeyHandle native_openssl_load_private_key_from_pem(OpenSslHandle handle, byte[] buffer, int len);
Example #24
0
		extern static int native_openssl_close (OpenSslHandle handle);
Example #25
0
 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);
Example #26
0
		extern static int native_openssl_bind (OpenSslHandle handle, byte[] ip, int port);
Example #27
0
 extern static int native_openssl_set_certificate(
     OpenSslHandle handle, CertificateHandle certificate, PrivateKeyHandle privateKey);
Example #28
0
		extern static int native_openssl_read (OpenSslHandle handle, byte[] buffer, int offset, int size);
Example #29
0
 extern static void native_openssl_set_certificate_verify(OpenSslHandle handle, int mode, VerifyCallback verify_cb, CertificateVerifyCallback cert_cb, int depth);
Example #30
0
		extern static PrivateKeyHandle native_openssl_load_private_key_from_pem (OpenSslHandle handle, byte[] buffer, int len);
Example #31
0
 extern static int native_openssl_shutdown(OpenSslHandle handle);
Example #32
0
		extern static int native_openssl_set_certificate (
			OpenSslHandle handle, CertificateHandle certificate, PrivateKeyHandle privateKey);
Example #33
0
 extern static short native_openssl_get_current_cipher(OpenSslHandle handle);
Example #34
0
		extern static int native_openssl_shutdown (OpenSslHandle handle);
Example #35
0
 extern static int native_openssl_set_cipher_list(OpenSslHandle handle, byte[] ciphers, int count);
Example #36
0
		extern static int native_openssl_set_cipher_list (OpenSslHandle handle, byte[] ciphers, int count);
Example #37
0
		extern static int native_openssl_set_dh_params (OpenSslHandle handle, byte[] p, int p_len, byte[] g, int b_len);
Example #38
0
		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);
		}
Example #39
0
 extern static int native_openssl_set_dh_params(OpenSslHandle handle, byte[] p, int p_len, byte[] g, int b_len);