Skip to content

Commit

Permalink
/vsicurl/: automatically detect signed URLs where host ends with a po…
Browse files Browse the repository at this point in the history
…rt number; also detect signed URLs as created iwth the AWS4-HMAC-SHA256 method (fixes #1456)
  • Loading branch information
rouault committed Apr 18, 2019
1 parent 7d4fe9a commit fceb74a
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions gdal/port/cpl_vsil_curl.cpp
Expand Up @@ -645,9 +645,13 @@ static bool VSICurlIsS3LikeSignedURL( const char* pszURL )
{
return
(strstr(pszURL, ".s3.amazonaws.com/") != nullptr ||
strstr(pszURL, ".storage.googleapis.com/") != nullptr) &&
strstr(pszURL, ".s3.amazonaws.com:") != nullptr ||
strstr(pszURL, ".storage.googleapis.com/") != nullptr ||
strstr(pszURL, ".storage.googleapis.com:") != nullptr) &&
(strstr(pszURL, "&Signature=") != nullptr ||
strstr(pszURL, "?Signature=") != nullptr);
strstr(pszURL, "?Signature=") != nullptr ||
strstr(pszURL, "&X-Amz-Signature=") != nullptr ||
strstr(pszURL, "?X-Amz-Signature=") != nullptr);
}

/************************************************************************/
Expand All @@ -659,9 +663,16 @@ static GIntBig VSICurlGetExpiresFromS3LikeSignedURL( const char* pszURL )
const char* pszExpires = strstr(pszURL, "&Expires=");
if( pszExpires == nullptr )
pszExpires = strstr(pszURL, "?Expires=");
if( pszExpires != nullptr )
return CPLAtoGIntBig(pszExpires + strlen("&Expires="));

pszExpires = strstr(pszURL, "?X-Amz-Expires=");
if( pszExpires == nullptr )
return 0;
return CPLAtoGIntBig(pszExpires + strlen("&Expires="));
pszExpires = strstr(pszURL, "?X-Amz-Expires=");
if( pszExpires != nullptr )
return CPLAtoGIntBig(pszExpires + strlen("&X-Amz-Expires="));

return 0;
}

/************************************************************************/
Expand Down

0 comments on commit fceb74a

Please sign in to comment.