Inheritance: IDisposable
Ejemplo n.º 1
0
        public TlsServerStream(Socket socket)
        {
            _socket = socket;

            if (UseOpenSSL)
            {
#if OPENSSL
                if (_OpenSslContext == null)
                {
                    if (PemFileName == String.Empty)
                    {
                        string[] files = Directory.GetFiles(Dicom.Debug.GetStartDirectory(), "*.pem", SearchOption.TopDirectoryOnly);
                        if (files.Length > 0)
                        {
                            PemFileName = files[0];
                        }
                        else
                        {
                            throw new Exception("Unable to find SSL/TLS server certificate.");
                        }
                    }
                    _OpenSslContext             = new OpenSslContext(OpenSslProtocol.AutoDetect, true);
                    _OpenSslContext.Certificate = OpenSslCertificate.FromPemFile(PemFileName);
                    _OpenSslContext.PrivateKey  = OpenSslPrivateKey.FromPemFile(PemFileName);
                }
                _stream = new OpenSslStream(_socket, _OpenSslContext);
#else
                throw new NotImplementedException();
#endif
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes server connection
 /// </summary>
 /// <param name="socket"></param>
 /// <param name="protocol"></param>
 /// <param name="certificate"></param>
 /// <param name="privatekey"></param>
 public OpenSslStream(Socket socket, OpenSslProtocol protocol, OpenSslCertificate certificate, OpenSslPrivateKey privatekey)
 {
     context                = new OpenSslContext(protocol, true);
     connection             = new OpenSslConnection(context);
     connection.Certificate = certificate;
     connection.PrivateKey  = privatekey;
     connection.Accept(socket);
 }
Ejemplo n.º 3
0
        public TlsServerStream(Socket socket)
        {
            _socket = socket;

            if (UseOpenSSL)
            {
            #if OPENSSL
                if (_OpenSslContext == null)
                {
                    if (PemFileName == String.Empty)
                    {
                        string[] files = Directory.GetFiles(Dicom.Debug.GetStartDirectory(), "*.pem", SearchOption.TopDirectoryOnly);
                        if (files.Length > 0)
                            PemFileName = files[0];
                        else
                            throw new Exception("Unable to find SSL/TLS server certificate.");
                    }
                    _OpenSslContext = new OpenSslContext(OpenSslProtocol.AutoDetect, true);
                    _OpenSslContext.Certificate = OpenSslCertificate.FromPemFile(PemFileName);
                    _OpenSslContext.PrivateKey = OpenSslPrivateKey.FromPemFile(PemFileName);
                }
                _stream = new OpenSslStream(_socket, _OpenSslContext);
            #else
                throw new NotImplementedException();
            #endif
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes client connection
 /// </summary>
 /// <param name="socket"></param>
 public OpenSslStream(Socket socket, OpenSslProtocol protocol)
 {
     context = new OpenSslContext(protocol, false);
     connection = new OpenSslConnection(context);
     connection.Connect(socket);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes server connection
 /// </summary>
 /// <param name="socket"></param>
 /// <param name="ctx"></param>
 public OpenSslStream(Socket socket, OpenSslContext ctx)
 {
     context = ctx;
     connection = new OpenSslConnection(context);
     connection.Accept(socket);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes server connection
 /// </summary>
 /// <param name="socket"></param>
 /// <param name="protocol"></param>
 /// <param name="certificate"></param>
 /// <param name="privatekey"></param>
 public OpenSslStream(Socket socket, OpenSslProtocol protocol, OpenSslCertificate certificate, OpenSslPrivateKey privatekey)
 {
     context = new OpenSslContext(protocol, true);
     connection = new OpenSslConnection(context);
     connection.Certificate = certificate;
     connection.PrivateKey = privatekey;
     connection.Accept(socket);
 }
Ejemplo n.º 7
0
 public OpenSslConnection(OpenSslContext ctx)
 {
     _context = ctx;
     _ssl = OpenSslUtility.AssertNotNull(OpenSslNative.SSL_new(_context.Handle));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes client connection
 /// </summary>
 /// <param name="socket"></param>
 public OpenSslStream(Socket socket, OpenSslProtocol protocol)
 {
     context    = new OpenSslContext(protocol, false);
     connection = new OpenSslConnection(context);
     connection.Connect(socket);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Initializes server connection
 /// </summary>
 /// <param name="socket"></param>
 /// <param name="ctx"></param>
 public OpenSslStream(Socket socket, OpenSslContext ctx)
 {
     context    = ctx;
     connection = new OpenSslConnection(context);
     connection.Accept(socket);
 }
Ejemplo n.º 10
0
 public OpenSslConnection(OpenSslContext ctx)
 {
     _context = ctx;
     _ssl     = OpenSslUtility.AssertNotNull(OpenSslNative.SSL_new(_context.Handle));
 }