Exemple #1
0
        public Writer(IConnection connection, Stream stream, BlockingQueue<Notification> queue, Archive archive)
        {
            this.connection = connection;
            this.stream = stream;
            this.queue = queue;
            this.archive = archive;

            thread = new Thread(new ThreadStart(Run));
            thread.Start();
        }
Exemple #2
0
        public Connection(string host, int port, string p12File, string p12FilePassword, BlockingQueue<Notification> queue, Archive archive, Service service)
        {
            this.service = service;

            if (string.IsNullOrEmpty(p12FilePassword))
                cert = new X509Certificate2(System.IO.File.ReadAllBytes(p12File), "", X509KeyStorageFlags.MachineKeySet); // TODO not tested
            else
                cert = new X509Certificate2(System.IO.File.ReadAllBytes(p12File), p12FilePassword, X509KeyStorageFlags.MachineKeySet);
            certCollection = new X509CertificateCollection();
            certCollection.Add(cert);

            tcpClient = new TcpClient(host, port);

            stream = new SslStream(tcpClient.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate),
                new LocalCertificateSelectionCallback(SelectLocalCertificate));
            stream.AuthenticateAsClient(host, certCollection, System.Security.Authentication.SslProtocols.Ssl3, false);
            if (!stream.IsMutuallyAuthenticated || !stream.CanWrite)
            {
                throw new Exception();
            }

            reader = new Reader(this, stream, archive);
            writer = new Writer(this, stream, queue, archive);
        }
Exemple #3
0
 private void Connect()
 {
     isConnectionAborting = false;
     archive = new Archive();
     string host;
     if (isSandbox)
         host = sandboxHost;
     else
         host = productHost;
     connection = new Connection(host, port, p12File, p12FilePassword, queue, archive, this);
 }