You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When signing a resource URL with CloudFrontUtilities::getSignedUrlWithCannedPolicy, if the given URL contains a port number in the authority, the signature will be generated based on the original string with the port, but the port will be stripped from the actual string that is returned. The signature will be invalid.
Expected Behavior
CloudFrontUtilities::getSignedUrlWithCannedPolicy should not modify the URL authority that it is given.
Current Behavior
Current behavior is that CloudFrontUtilities::getSignedUrlWithCannedPolicy always strips the port number from the authority given, after it has already generated a signature.
Reproduction Steps
CloudFrontUtilitiescloudFrontUtilities = CloudFrontUtilities.create();
StringurlToSign = "https://abc.cloudfront.net:443/foo/bar.html";
StringsignedUrl = cloudFrontUtilities.getSignedUrlWithCannedPolicy(signer -> signer
.resourceUrl(uri.toString())
.keyPairId(keyName)
.privateKey(privateKey)
.expirationDate(normalizedExpires))
.url();
// signedUrl will be "https://abc.cloudfront.net/foo/bar.html", but the signature was// signed for "https://abc.cloudfront.net:443/foo/bar.html".assertsignedUrl.startsWith(urlToSign);
Possible Solution
When reconstructing the signed URL, use the original URL's authority string unmodified, or add conditional logic to append the port to the reconstructed URL if given.
We sign "dummy URLs" in our unit and local application tests. These dummy URLs sometimes point to local servers and not real CloudFront hosts. This behavior broke such code when we upgraded from the AWS SDK for Java v1, since these local servers don't run on port 80 or 443.
In general, modifying the URL authority seems unexpected and unnecessary anyway.
AWS Java SDK version used
2.24.13
JDK version used
1.8.0_332
Operating System and version
macOS 13.6.5
The text was updated successfully, but these errors were encountered:
This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
Describe the bug
When signing a resource URL with
CloudFrontUtilities::getSignedUrlWithCannedPolicy
, if the given URL contains a port number in the authority, the signature will be generated based on the original string with the port, but the port will be stripped from the actual string that is returned. The signature will be invalid.Expected Behavior
CloudFrontUtilities::getSignedUrlWithCannedPolicy
should not modify the URL authority that it is given.Current Behavior
Current behavior is that
CloudFrontUtilities::getSignedUrlWithCannedPolicy
always strips the port number from the authority given, after it has already generated a signature.Reproduction Steps
Possible Solution
When reconstructing the signed URL, use the original URL's authority string unmodified, or add conditional logic to append the port to the reconstructed URL if given.
Possible implementation (untested):
Additional Information/Context
We sign "dummy URLs" in our unit and local application tests. These dummy URLs sometimes point to local servers and not real CloudFront hosts. This behavior broke such code when we upgraded from the AWS SDK for Java v1, since these local servers don't run on port 80 or 443.
In general, modifying the URL authority seems unexpected and unnecessary anyway.
AWS Java SDK version used
2.24.13
JDK version used
1.8.0_332
Operating System and version
macOS 13.6.5
The text was updated successfully, but these errors were encountered: