private SafeguardA2AContext(string networkAddress, CertificateContext clientCertificate, int apiVersion,
                                    bool ignoreSsl)
        {
            _networkAddress = networkAddress;
            _apiVersion     = apiVersion;

            var safeguardA2AUrl = $"https://{_networkAddress}/service/a2a/v{_apiVersion}";

            _a2AClient = new RestClient(safeguardA2AUrl);

            var safeguardCoreUrl = $"https://{_networkAddress}/service/core/v{_apiVersion}";

            _coreClient = new RestClient(safeguardCoreUrl);

            if (ignoreSsl)
            {
                _ignoreSsl = true;
                _a2AClient.RemoteCertificateValidationCallback  += (sender, certificate, chain, errors) => true;
                _coreClient.RemoteCertificateValidationCallback += (sender, certificate, chain, errors) => true;
            }

            _clientCertificate            = clientCertificate.Clone();
            _a2AClient.ClientCertificates = new X509Certificate2Collection()
            {
                _clientCertificate.Certificate
            };
            _coreClient.ClientCertificates = new X509Certificate2Collection()
            {
                _clientCertificate.Certificate
            };
        }
Example #2
0
 public SafeguardEventListener(string eventUrl, CertificateContext clientCertificate, SecureString apiKey,
     bool ignoreSsl, RemoteCertificateValidationCallback validationCallback) : this(eventUrl, ignoreSsl, validationCallback)
 {
     _clientCertificate = clientCertificate.Clone();
     if (apiKey == null)
         throw new ArgumentException("Parameter may not be null", nameof(apiKey));
     _apiKey = apiKey.Copy();
 }
Example #3
0
 public SafeguardEventListener(string eventUrl, CertificateContext clientCertificate, IEnumerable<SecureString> apiKeys,
     bool ignoreSsl, RemoteCertificateValidationCallback validationCallback) : this(eventUrl, ignoreSsl, validationCallback)
 {
     _clientCertificate = clientCertificate.Clone();
     if (apiKeys == null)
         throw new ArgumentException("Parameter may not be null", nameof(apiKeys));
     _apiKeys = new List<SecureString>();
     foreach (var apiKey in apiKeys)
         _apiKeys.Add(apiKey.Copy());
     if (!_apiKeys.Any())
         throw new ArgumentException("Parameter must include at least one item", nameof(apiKeys));
 }
Example #4
0
 private CertificateAuthenticator(string networkAddress, CertificateContext clientCertificate, int apiVersion,
                                  bool ignoreSsl, RemoteCertificateValidationCallback validationCallback) : base(networkAddress, apiVersion, ignoreSsl, validationCallback)
 {
     _clientCertificate = clientCertificate.Clone();
 }
 private CertificateAuthenticator(string networkAddress, CertificateContext clientCertificate, int apiVersion,
                                  bool ignoreSsl) : base(networkAddress, apiVersion, ignoreSsl)
 {
     _clientCertificate = clientCertificate.Clone();
 }