protected static bool UseV4Signing(bool useSigV4Setting, IRequest request, IClientConfig config)
{
if (useSigV4Setting || request.UseSigV4 || config.SignatureVersion == "4")
return true;
// do a cascading series of checks to try and arrive at whether we have
// a recognisable region; this is required to use the AWS4 signer
RegionEndpoint r = null;
if (!string.IsNullOrEmpty(request.AuthenticationRegion))
r = RegionEndpoint.GetBySystemName(request.AuthenticationRegion);
if (r == null && !string.IsNullOrEmpty(config.ServiceURL))
{
var parsedRegion = AWSSDKUtils.DetermineRegion(config.ServiceURL);
if (!string.IsNullOrEmpty(parsedRegion))
r = RegionEndpoint.GetBySystemName(parsedRegion);
}
if (r == null && config.RegionEndpoint != null)
r = config.RegionEndpoint;
if (r != null)
{
var endpoint = r.GetEndpointForService(config.RegionEndpointServiceName, config.UseDualstackEndpoint);
if (endpoint != null && (endpoint.SignatureVersionOverride == "4" || string.IsNullOrEmpty(endpoint.SignatureVersionOverride)))
return true;
}
return false;
}