internal static string GetUrl(IClientConfig config, RegionEndpoint regionEndpoint) { var endpoint = regionEndpoint.GetEndpointForService( config.RegionEndpointServiceName, config.ToGetEndpointForServiceOptions()); string url = new Uri(string.Format(CultureInfo.InvariantCulture, "{0}{1}", config.UseHttp ? "http://" : "https://", endpoint.Hostname)).AbsoluteUri; return(url); }
public static RegionEndpoint.Endpoint GetEndpointForService(this RegionEndpoint endpoint, IClientConfig config) { return(endpoint.GetEndpointForService(config.RegionEndpointServiceName, config.ToGetEndpointForServiceOptions())); }
/// <summary> /// Inspects the supplied evidence to determine if sigv4 or sigv2 signing should be used /// </summary> /// <param name="useSigV4Setting">Global setting for the service</param> /// <param name="request">The request.</param> /// <param name="config">Configuration for the client</param> /// <returns>True if signature v4 request signing should be used, false if v2 signing should be used</returns> protected static bool UseV4Signing(bool useSigV4Setting, IRequest request, IClientConfig config) { if (request.SignatureVersion == SignatureVersion.SigV4 || config.SignatureVersion == "4" || (useSigV4Setting && config.SignatureVersion != "2")) { return(true); } else { // 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.ToGetEndpointForServiceOptions()); if (endpoint != null && (endpoint.SignatureVersionOverride == "4" || string.IsNullOrEmpty(endpoint.SignatureVersionOverride))) { return(true); } } return(false); } }