Esempio n. 1
0
        public BackupClient(string endpoint, string authKey, string certificateIdentity)
        {
            // Create a Tcp binding with transport security via x.509 certificate
            NetTcpBinding binding = new NetTcpBinding(SecurityMode.Transport);

            // No client credentials are required
            // (The credentials are in the storage account connection strings)
            binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;

            this.authKey = authKey;

            try
            {
                if (certificateIdentity != null)
                {
                    EndpointAddress address = new EndpointAddress(new Uri(endpoint), new DnsEndpointIdentity(certificateIdentity));
                    this.factory = new ChannelFactory<IBackupService>(binding, address);
                }
                else
                {
                    this.factory = new ChannelFactory<IBackupService>(binding, endpoint);
                }

                // Since certificates do not need to be from a certification authority, set the certificate validation to none
                this.factory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;

                this.service = this.factory.CreateChannel();

                // Switch this line with the one above to run the backup service locally
                //this.service = new BackupService(authKey);
            }
            catch (Exception)
            {
                // The specified endpoint is invalid
            }

            this.backup = new Backup();
        }
 public BackupService(string authKey)
 {
     this.authKey = authKey;
     this.backup = new Backup();
 }