Example #1
0
 public static TlsServerProtocol ConnectPskTlsServer(TlsPskIdentityManager pskManager, Stream stream)
 {
     try
     {
         PskTlsServer      server   = new PskTlsServer2(pskManager);
         TlsServerProtocol protocol = new TlsServerProtocol(stream, new SecureRandom());
         protocol.Accept(server);
         return(protocol);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Exception in TLS protocol connnection '{0}'", ex.Message);
         throw ex;
     }
 }
Example #2
0
        public static TlsServerProtocol ConnectPskTlsServerNonBlocking(Dictionary <string, byte[]> psks)
        {
            try
            {
                TlsPskIdentityManager pskTlsManager = new PskIdentityManager(psks);
                PskTlsServer2         server        = new PskTlsServer2(pskTlsManager);
                TlsServerProtocol     protocol      = new TlsServerProtocol(new SecureRandom());
                protocol.Accept(server);

                return(protocol);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception in TLS protocol connnection '{0}'", ex.Message);
                throw ex;
            }
        }
 public static TlsServerProtocol ConnectPskTlsServer(this TcpClient client, TlsPskIdentityManager pskManager, Stream stream)
 {
     try
     {
         PskTlsServer      server   = new PskTlsServer2(pskManager);
         TlsServerProtocol protocol = new TlsServerProtocol(stream, new SecureRandom());
         protocol.Accept(server);
         return(protocol);
     }
     catch (AggregateException ae)
     {
         string msg = String.Format("AggregateException in TLS protocol connnection '{0}'", ae.Flatten().InnerException.Message);
         Console.WriteLine(msg);
         throw new Exception(msg, ae.Flatten().InnerException);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Exception in TLS protocol connnection '{0}'", ex.Message);
         throw ex;
     }
 }