public NFeRetAutorizacao4(string url, X509Certificate certificado, int timeOut) { SoapVersion = SoapProtocolVersion.Soap12; Url = url; Timeout = timeOut; ClientCertificates.Add(certificado); }
public RecepcaoEvento4SVAN(string url, X509Certificate certificado, int timeOut) { SoapVersion = SoapProtocolVersion.Soap12; Url = url; Timeout = timeOut; ClientCertificates.Add(certificado); }
public NfeStatusServico4NFeAN(string url, X509Certificate certificado, int timeOut) { SoapVersion = SoapProtocolVersion.Soap12; Url = url; Timeout = timeOut; ClientCertificates.Add(certificado); }
/// <summary> /// Set the client certificate provider (NetStandard implementation) /// </summary> /// <param name="provider">The provider for client certificates on this platform</param> public virtual void SetClientCertificates(Abstractions.IClientCertificateProvider provider) { ClientCertificates.Clear(); if (provider is IClientCertificateProvider netProvider) { ClientCertificates.AddRange(netProvider.Certificates); } }
protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { ClientCertificates.Add(new X509Certificate()); //var certificate = _certificateProvider.Load(_certificate, _password); //var requestHandler = new WebRequestHandler(); //requestHandler.ClientCertificates.Add(certificate); return(await base.SendAsync(request, cancellationToken)); }
/// <summary> /// 配置添加客户端安全证书 /// </summary> /// <param name="certificatePath">客户端安全证书路径</param> public TRequest ConfigAddClientCertificate(string certificatePath) { if (certificatePath.IsEmpty()) { return(This()); } ClientCertificates.Add(new X509Certificate2(certificatePath)); return(This()); }
public PackageSource Clone() { return(new PackageSource(Source, Name, IsEnabled, IsOfficial, IsPersistable) { Description = Description, Credentials = Credentials?.Clone(), ClientCertificates = ClientCertificates?.ToList(), IsMachineWide = IsMachineWide, ProtocolVersion = ProtocolVersion, }); }
public CTeDistDFeInteresse(WsdlConfiguracao configuracao) { SoapVersion = SoapProtocolVersion.Soap12; Url = configuracao.Url; Timeout = configuracao.TimeOut; ClientCertificates.Add(configuracao.CertificadoDigital); cteCabecMsg = new cteCabecMsg(); cteCabecMsg.versaoDados = configuracao.Versao; cteCabecMsg.cUF = configuracao.CodigoIbgeEstado; }
public DockerHttpClientHandler(IConfiguration configuration) { var certificateFileName = configuration.GetCertificateFileName(); if (!string.IsNullOrEmpty(certificateFileName)) { var clientCertificate = new X509Certificate2(certificateFileName, configuration.GetCertificatePassword()); ClientCertificates.Add(clientCertificate); ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => true; } }
/// <summary> /// Custom HTTP Handler to delegate the processing of HTTP requests and extending it. /// </summary> /// <param name="context">Cake Context the request is geting </param> /// <param name="settings">HttpSettings to apply to the inner handler</param> public CakeHttpClientHandler(ICakeContext context, HttpSettings settings) { _Context = context ?? throw new ArgumentNullException(nameof(context)); _Settings = settings ?? throw new ArgumentException(nameof(settings)); UseDefaultCredentials = settings.UseDefaultCredentials; UseCookies = false; foreach (var clientCertificate in settings.ClientCertificates) { ClientCertificates.Add(clientCertificate); } }
/// <summary> /// 配置添加客户端安全证书 /// </summary> /// <param name="certificatePath">客户端安全证书路径</param> /// <param name="certificatePassword">客户端安全证书密码</param> public TRequest ConfigAddClientCertificate(string certificatePath, string certificatePassword) { if (certificatePath.IsEmpty()) { return(This()); } if (certificatePassword.IsEmpty()) { return(ConfigAddClientCertificate(certificatePath)); } ClientCertificates.Add(new X509Certificate2(certificatePath, certificatePassword, X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.MachineKeySet)); return(This()); }
/// <summary> /// Constructor that always uses a client certificate if one exist for TLS client authentication. /// </summary> /// <param name="client">Backpointer to OioIdwsClient</param> /// <param name="accessToken">An optional access token. Can be used if client already has access to a cached token.</param> public OioIdwsRequestHandler(OioIdwsClient client, AccessToken.AccessToken accessToken) { if (client == null) { throw new ArgumentNullException(nameof(client)); } _client = client; _accessToken = accessToken; //We can't know in advance whether it's a Bearer/Holder-of-key token we're going to work with. Either way we just add the certificate to the request, if given if (client.Settings.ClientCertificate != null) { ClientCertificates.Add(client.Settings.ClientCertificate); } }
public DKApiMessageHandler() { var username = Environment.GetEnvironmentVariable(EnvironmentVariableDKApiUsername); var password = Environment.GetEnvironmentVariable(EnvironmentVariableDKApiPassword); AuthHeaderValue = new AuthenticationHeaderValue( "Basic", Convert.ToBase64String( System.Text.ASCIIEncoding.ASCII.GetBytes( $"{username}:{password}"))); // Use client ssh certificate var certPath = Environment.GetEnvironmentVariable(EnvironmentVariableDKApiCertPath); var certPass = Environment.GetEnvironmentVariable(EnvironmentVariableDKApiCertPass); var cert = new X509Certificate2(certPath, certPass); ClientCertificates.Add(cert); }
public DefaultHttpHandler(IConnection connection) { if (connection != null) { _connection = connection; } else { throw new ArgumentNullException("connection"); } Credentials = _connection.Credentials; #if PORTABLE if (this.SupportsPreAuthenticate()) { PreAuthenticate = true; } #elif NET45 || NETSTANDARD PreAuthenticate = true; #endif if (_connection.CookieContainer != null) { CookieContainer = _connection.CookieContainer; } #if !PORTABLE if (_connection.Proxy != null) { Proxy = _connection.Proxy; } #endif #if (NET4 || NET45 || NETSTANDARD) foreach (X509Certificate cert in _connection.Certificates) { ClientCertificates.Add(cert); } #endif }
protected override async Task <HttpResponseMessage> SendAsync( HttpRequestMessage request, CancellationToken cancellationToken) { string serverName = request.RequestUri.Host; if (ClientCertificates.Contains(_certMap[serverName])) { try { var response = await base.SendAsync(request, cancellationToken); return(response); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadKey(); throw; } } else { ClientCertificates.Clear(); ClientCertificates.Add(_certMap[serverName]); try { var response = await base.SendAsync(request, cancellationToken); return(response); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadKey(); throw; } } }
public void Add(ClientCertificate certificate) { using (var entities = IdentityServerConfigurationContext.Get()) { var record = (from entry in entities.ClientCertificates where entry.UserName.Equals(certificate.UserName, StringComparison.OrdinalIgnoreCase) && entry.Thumbprint.Equals(certificate.Thumbprint, StringComparison.OrdinalIgnoreCase) select entry) .SingleOrDefault(); if (record == null) { record = new ClientCertificates { UserName = certificate.UserName, Thumbprint = certificate.Thumbprint }; entities.ClientCertificates.Add(record); } record.Description = certificate.Description; entities.SaveChanges(); } }
public IWebClientRequest UseClientCertificate(X509Certificate2 clientCertificate) { ClientCertificates.Add(clientCertificate); return(this); }
public CollegeLicenceClientHandler() { ClientCertificates.Add(new X509Certificate2(PrimeConstants.PHARMANET_SSL_CERT_FILENAME, PrimeConstants.PHARMANET_SSL_CERT_PASSWORD)); ClientCertificateOptions = ClientCertificateOption.Manual; }
internal IAsyncResult BeginGetConnection(ServicePoint servicePoint, ContextAwareResult outerResult, AsyncCallback callback, object state) { if (Logging.On) { Logging.Associate(Logging.Web, this, servicePoint); } Debug.Assert(servicePoint != null, "servicePoint was null from SmtpTransport"); if (EnableSsl && ClientCertificates != null && ClientCertificates.Count > 0) { connectionPool = ConnectionPoolManager.GetConnectionPool(servicePoint, ClientCertificates.GetHashCode().ToString(NumberFormatInfo.InvariantInfo), m_CreateConnectionCallback); } else { connectionPool = ConnectionPoolManager.GetConnectionPool(servicePoint, "", m_CreateConnectionCallback); } ConnectAndHandshakeAsyncResult result = new ConnectAndHandshakeAsyncResult(this, servicePoint.Host, servicePoint.Port, outerResult, callback, state); result.GetConnection(false); return(result); }
public CertMessageHandler() { ClientCertificateOptions = ClientCertificateOption.Manual; ClientCertificates.Add(HttpClientHelpers.GetCert()); }
public ScopedHttpClientHandler(Uri certFile, string certPass) { AllowAutoRedirect = false; ClientCertificates.Add(GetCertificate(certFile, certPass)); }
public CollegeLicenceClientHandler() { ClientCertificates.Add(new X509Certificate2(PrimeEnvironment.PharmanetApi.SslCertFilename, PrimeEnvironment.PharmanetApi.SslCertPassword)); ClientCertificateOptions = ClientCertificateOption.Manual; }
//public BankIDHttpClientHandler() //{ // _telemetryClient = new TelemetryClient(); //} public BankIDHttpClientHandler(BankIDServiceSettings bankIdServiceSettings, TelemetryClient telemetryClient) { //TelemetryConfiguration.Active _telemetryClient = telemetryClient; // new TelemetryClient(); _bankIdServiceSettings = bankIdServiceSettings; //var bankIdServiceSettings = new BankIDServiceSettings(env); AllowAutoRedirect = false; AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip; SslProtocols = SslProtocols.Tls12; // Hosting dependent config var hosting = Environment.GetEnvironmentVariable("ASPNETCORE_HOSTING"); if (!string.IsNullOrEmpty(hosting) && hosting.Equals("Azure")) { // https://docs.microsoft.com/en-us/azure/app-service/app-service-web-ssl-cert-load // server certificate X509Store certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser); certStore.Open(OpenFlags.ReadOnly); X509Certificate2Collection caCertCollection = certStore.Certificates.Find( X509FindType.FindByThumbprint, _bankIdServiceSettings.CaCertThumbprint, false); if (caCertCollection.Count > 0) { X509Certificate2 caCert = caCertCollection[0]; var validator = new RootCaValidator(caCert); ServerCertificateCustomValidationCallback = validator.Validate; _telemetryClient.TrackTrace($"Loaded CA Cert {caCert.SubjectName?.Name}, {caCert.Thumbprint}", SeverityLevel.Information); } else { _telemetryClient.TrackTrace($"Could not load CA Cert", SeverityLevel.Critical); } X509Certificate2Collection rpCertCollection = certStore.Certificates.Find( X509FindType.FindByThumbprint, _bankIdServiceSettings.RpCertThumbprint, false); if (rpCertCollection.Count > 0) { X509Certificate2 rpCert = rpCertCollection[0]; ClientCertificates.Add(rpCert); _telemetryClient.TrackTrace($"Loaded RP Cert {rpCert.SubjectName?.Name}, {rpCert.Thumbprint}", SeverityLevel.Information); } else { _telemetryClient.TrackTrace($"Could not load RP Cert", SeverityLevel.Critical); } _telemetryClient.Flush(); certStore.Close(); } else { // Local SecureString secureString = new SecureString(); "qwerty123".ToCharArray().ToList().ForEach(p => secureString.AppendChar(p)); var rootCa = new X509Certificate2(_bankIdServiceSettings.CaCert); var validator = new RootCaValidator(rootCa); ServerCertificateCustomValidationCallback = validator.Validate; ClientCertificates.Add(new X509Certificate2(_bankIdServiceSettings.RpCert, secureString)); } }