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(); } }
/// <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); }
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(); } }
/// <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); }
/// <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); }
public OpenSslConnection(OpenSslContext ctx) { _context = ctx; _ssl = OpenSslUtility.AssertNotNull(OpenSslNative.SSL_new(_context.Handle)); }