protected override void ProcessRecord() { HttpSigningConfiguration httpConfig = new HttpSigningConfiguration() { KeyId = this.ApiKeyId, KeyFilePath = this.ApiKeyFilePath, HttpSigningHeader = this.HttpSigningHeader }; if (this.HttpSigningHeader.Contains("(expires)")) { if (SignatureValidityPeriod <= 0) { throw new Exception("SignatureValidityPeriod must be greater than 0 seconds."); } else { httpConfig.SignatureValidityPeriod = SignatureValidityPeriod; } } if (HashAlgorithm.Equals("sha256")) { httpConfig.HashAlgorithm = HashAlgorithmName.SHA256; } else if (HashAlgorithm.Equals("sha512")) { httpConfig.HashAlgorithm = HashAlgorithmName.SHA512; } if (!string.IsNullOrEmpty(ApiKeyPassPhrase)) { var secStr = new SecureString(); foreach (char ch in ApiKeyPassPhrase) { secStr.AppendChar(ch); } httpConfig.KeyPassPhrase = secStr; } Configuration config = new Configuration() { BasePath = BasePath, HttpSigningConfiguration = httpConfig }; CmdletBase.Config = config; if (Proxy != null) { config.Proxy = this.Proxy; } if (SkipCertificateCheck.IsPresent) { System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; } }
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureApi((context, options) => { ApiKeyToken apiKeyToken = new ApiKeyToken(context.Configuration["<token>"], timeout: TimeSpan.FromSeconds(1)); options.AddTokens(apiKeyToken); BearerToken bearerToken = new BearerToken(context.Configuration["<token>"], timeout: TimeSpan.FromSeconds(1)); options.AddTokens(bearerToken); BasicToken basicToken = new BasicToken(context.Configuration["<username>"], context.Configuration["<password>"], timeout: TimeSpan.FromSeconds(1)); options.AddTokens(basicToken); HttpSigningConfiguration config = new HttpSigningConfiguration("<keyId>", "<keyFilePath>", null, new List <string>(), HashAlgorithmName.SHA256, "<signingAlgorithm>", 0); HttpSignatureToken httpSignatureToken = new HttpSignatureToken(config, timeout: TimeSpan.FromSeconds(1)); options.AddTokens(httpSignatureToken); OAuthToken oauthToken = new OAuthToken(context.Configuration["<token>"], timeout: TimeSpan.FromSeconds(1)); options.AddTokens(oauthToken); });