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