Esempio 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();
            }
        }
Esempio 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);
 }
Esempio n. 3
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);
 }