コード例 #1
0
ファイル: Writer.cs プロジェクト: hajimen/flowerflower
        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();
        }
コード例 #2
0
ファイル: Connection.cs プロジェクト: hajimen/flowerflower
        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);
        }
コード例 #3
0
ファイル: Service.cs プロジェクト: hajimen/flowerflower
 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);
 }