public OrionInfoServiceCertificate(bool v3 = false)
 {
     _endpoint = v3 ? Settings.Default.OrionV3EndpointPathCertificate : Settings.Default.OrionEndpointPathCertificate;
     _endpointConfigName = "OrionCertificateTcpBinding";
     _binding = new NetTcpBinding("Certificate");
     _credentials = new MyCertificateCredential(Settings.Default.CertificateSubjectName, StoreLocation.LocalMachine, StoreName.My);
 }
Пример #2
0
 public OrionInfoServiceCertificate(bool v3 = false)
 {
     _endpoint           = v3 ? Settings.Default.OrionV3EndpointPathCertificate : Settings.Default.OrionEndpointPathCertificate;
     _endpointConfigName = "OrionCertificateTcpBinding";
     _binding            = new NetTcpBinding("Certificate");
     _credentials        = new MyCertificateCredential(Settings.Default.CertificateSubjectName, StoreLocation.LocalMachine, StoreName.My);
 }
Пример #3
0
        public OrionInfoServiceCertificate(bool v3 = false)
        {
            _endpoint = v3
                ? Settings.Default.OrionV3EndpointPathCertificate
                : Settings.Default.OrionEndpointPathCertificate;
            _endpointConfigName = "OrionCertificateTcpBinding";
            _binding            = new NetTcpBinding("Certificate");
            _credentials        = new MyCertificateCredential(Settings.Default.CertificateSubjectName,
                                                              StoreLocation.LocalMachine, StoreName.My);

            // call here before the service is connected, because otherwise the message cant be delivered to the UI.
            CustomCertificateValidator.ValidateCertPresent();
        }
Пример #4
0
        private InfoServiceProxy ConnectNetTcp()
        {
            InfoServiceProxy  infoServiceProxy;
            EndpointAddresses addresses = V2.IsPresent ? (EndpointAddresses) new V2EndpointAddresses() : new V3EndpointAddresses();

            if (Trusted.IsPresent)
            {
                var binding = new NetTcpBinding {
                    MaxReceivedMessageSize = int.MaxValue, MaxBufferSize = int.MaxValue
                };
                binding.Security.Mode = SecurityMode.Transport;
                binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;

                var uri = new Uri(string.Format(addresses.activeDirectory, Hostname ?? "localhost"));

                infoServiceProxy = new InfoServiceProxy(uri, binding, new WindowsCredential());
            }
            else if (Certificate.IsPresent)
            {
                var binding = new NetTcpBinding(SecurityMode.Transport)
                {
                    MaxReceivedMessageSize = int.MaxValue, MaxBufferSize = int.MaxValue
                };
                binding.Security.Mode = SecurityMode.Transport;
                binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate;
                binding.ReaderQuotas.MaxArrayLength             = int.MaxValue;
                binding.ReaderQuotas.MaxStringContentLength     = int.MaxValue;

                if (Streamed.IsPresent)
                {
                    binding.TransferMode       = TransferMode.Streamed;
                    binding.PortSharingEnabled = true;
                    binding.ReceiveTimeout     = new TimeSpan(15, 0, 0);
                    binding.SendTimeout        = new TimeSpan(15, 0, 0);
                }

                var address = (Streamed && !V2.IsPresent)
                                  ? ((V3EndpointAddresses)addresses).streamedCertificate
                                  : addresses.certificate;

                var uri = new Uri(string.Format(address, Hostname ?? "localhost"));

                ServiceCredentials credentials = new MyCertificateCredential("SolarWinds-Orion", StoreLocation.LocalMachine, StoreName.My);

                infoServiceProxy = new InfoServiceProxy(uri, binding, credentials);
            }
            else
            {
                var binding = new NetTcpBinding {
                    MaxReceivedMessageSize = int.MaxValue, MaxBufferSize = int.MaxValue
                };
                binding.Security.Mode = SecurityMode.TransportWithMessageCredential;
                binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;

                var uri = new Uri(string.Format(addresses.usernamePassword, Hostname ?? "localhost"));

                string username = string.Empty;
                string password = string.Empty;

                if (IsUserNamePresent)
                {
                    SecureString securePassword = StringToSecureString(Password);
                    Credential = new PSCredential(UserName, securePassword);
                }

                // the credential dialog adds a slash at the beginning, need to strip
                username = Credential.UserName.TrimStart('\\');
                password = SecureStringToString(Credential.Password);

                var credentials = new UsernameCredentials(username, password);

                infoServiceProxy = new InfoServiceProxy(uri, binding, credentials);
            }
            return(infoServiceProxy);
        }
Пример #5
0
        private InfoServiceProxy ConnectNetTcp()
        {
            InfoServiceProxy infoServiceProxy;
            EndpointAddresses addresses = V2.IsPresent ? (EndpointAddresses)new V2EndpointAddresses() : new V3EndpointAddresses();

            if (Trusted.IsPresent)
            {
                var binding = new NetTcpBinding {MaxReceivedMessageSize = int.MaxValue, MaxBufferSize = int.MaxValue};
                binding.Security.Mode = SecurityMode.Transport;
                binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;

                var uri = new Uri(string.Format(addresses.activeDirectory, Hostname ?? "localhost"));

                infoServiceProxy = new InfoServiceProxy(uri, binding, new WindowsCredential());
            }
            else if (Certificate.IsPresent)
            {
                var binding = new NetTcpBinding(SecurityMode.Transport) {MaxReceivedMessageSize = int.MaxValue, MaxBufferSize = int.MaxValue};
                binding.Security.Mode = SecurityMode.Transport;
                binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate;
                binding.ReaderQuotas.MaxArrayLength = int.MaxValue;
                binding.ReaderQuotas.MaxStringContentLength = int.MaxValue;

                if (Streamed.IsPresent)
                {
                    binding.TransferMode = TransferMode.Streamed;
                    binding.PortSharingEnabled = true;
                    binding.ReceiveTimeout = new TimeSpan(15,0,0);
                    binding.SendTimeout = new TimeSpan(15, 0, 0);
                }

                var address = (Streamed && !V2.IsPresent)
                                  ? ((V3EndpointAddresses) addresses).streamedCertificate
                                  : addresses.certificate;

                var uri = new Uri(string.Format(address, Hostname ?? "localhost"));

                ServiceCredentials credentials = new MyCertificateCredential("SolarWinds-Orion", StoreLocation.LocalMachine, StoreName.My);

                infoServiceProxy = new InfoServiceProxy(uri, binding, credentials);
            }
            else
            {
                var binding = new NetTcpBinding {MaxReceivedMessageSize = int.MaxValue, MaxBufferSize = int.MaxValue};
                binding.Security.Mode = SecurityMode.TransportWithMessageCredential;
                binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;

                var uri = new Uri(string.Format(addresses.usernamePassword, Hostname ?? "localhost"));

                string username = string.Empty;
                string password = string.Empty;

                if (IsUserNamePresent)
                {
                    SecureString securePassword = StringToSecureString(this.Password);
                    this.Credential = new PSCredential(this.UserName, securePassword);
                }

                // the credential dialog adds a slash at the beginning, need to strip
                username = Credential.UserName.TrimStart('\\');
                password = SecureStringToString(Credential.Password);

                var credentials = new UsernameCredentials(username, password);

                infoServiceProxy = new InfoServiceProxy(uri, binding, credentials);
            }
            return infoServiceProxy;
        }