-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: Add support for SHA256 in the CloudFront signers #3426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| -----BEGIN PRIVATE KEY----- | ||
| MIIBSgIBADCCASsGByqGSM44BAEwggEeAoGBAP4RyUV/qd4E/QPJ7IrjogSq073W | ||
| dinSable3aQYBeLsKVcnUg9n6Jfpw6o1WxsANZK8U6+vnG/hfc3OUKANcqaM57U6 | ||
| z3dTaRUR/SS85MLNLeofsnqtYVYNYgrqWpim6BJ6fG0ur9D7l9qwQTPCS6Jgw+/S | ||
| 543zKvTDUvh2ilztAhUAipnpPmXU/H9o6HUo7b6oULtaFZ8CgYAIGh6nNlHaDspr | ||
| vGKBTmdLWZsH6mtTQGjCfDQ3MkFJoutbfhjCWt5SY+BjvTbfF3qF/LyKdvr29Ps6 | ||
| L9lbFbCwnae3J1lpZMB2bE0iH8AiIxtl4Y4TG2QfqS1bmL2pm+KoCJabcw5pDbEs | ||
| Vv2Y4KN0Avi/8Xm6uwNIjjAvkxGi7AQWAhQPQOfoCwk7SSHhTGzsePLRb7VheA== | ||
| -----END PRIVATE KEY----- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| -----BEGIN PRIVATE KEY----- | ||
| MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgrYlqAmw042lSYigS | ||
| /hH1a8NamwSmZHOnIfkoDPMjHbKhRANCAAS70BK5GOWO0HlQcodlwYOKG45Ng7cd | ||
| agIYyRgZUEId3gsFY43KtQPcgKLUQ1NPOJyuFcYCtki460UsOV1ThTxP | ||
| -----END PRIVATE KEY----- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| -----BEGIN PUBLIC KEY----- | ||
| MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEu9ASuRjljtB5UHKHZcGDihuOTYO3 | ||
| HWoCGMkYGVBCHd4LBWONyrUD3ICi1ENTTzicrhXGArZIuOtFLDldU4U8Tw== | ||
| -----END PUBLIC KEY----- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| -----BEGIN PRIVATE KEY----- | ||
| MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAL1XcBtoCSzdyqqm | ||
| CFfh0XeLiuCtlE6bXUbscAbl7AUISzbQNKzgO1FwRBDMddfYyOQ/2nDPzLhgAK2E | ||
| Kv+dEi4/YEdLg2cbOaxjfhSn6ycwM+C502Ls/CtxHICcqs4cQs7BTlFfk32gy7Oq | ||
| kLTbTttIGMWasBAQHLhbJZstDp2vAgMBAAECgYAoujMqIgG/PeIHPPmUdcWJ0mFI | ||
| HO5GzlKNG/So9zICjxsmqjh6ay03Qk/R0TkT+dSUjEufcoNVsYjTyhc5rn6nR0SK | ||
| UL2IG5r6yFzlh+27u0/CzR1x61zWj01FwI8tacyR1tskyt7jqvT6eYFb1in2BDlE | ||
| qdNgTxVrjVBlxU6hkQJBAON8RGwO3g5Pxt0k0yQ6uSu3xj1/2uq4njKcoDgyFcNp | ||
| M7ZFW8SX0ZZw3wqSPlzs7mRI79b+G+M97nBw78kdKBkCQQDVEy4WnA3VRSlBRjVH | ||
| HwLyK7B9FaRJi70cb0JePnazEZS74FeT6BFW0HsNNeq+awCEcvemKpsOa8nr8QgM | ||
| K00HAkEA2keyS9GURz1Lf4VHSHtElOt5QCe/wvw1aDEcF/APK/t1UE+LN7/Jr0ZM | ||
| 7pLXXklGklneMXiQ/+K8OY5Ut7DPeQJAATjy8r5Cdg7HhdBZTecnpSwK/yy4nJNo | ||
| qlkZEGFbXPuk1s8asYaLUuwvSIwepKkIf7oJIbLs4NBNgEUJvsgg0QJBAJx2KEC9 | ||
| KMs82U4qjLE5vA87r4s4llGgvR+QsYfiwr8LUMlN47DLGrjNpb3JZ58j9Cw3zFPh | ||
| yLL0lGtqf49VRDs= | ||
| -----END PRIVATE KEY----- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| -----BEGIN PUBLIC KEY----- | ||
| MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9V3AbaAks3cqqpghX4dF3i4rg | ||
| rZROm11G7HAG5ewFCEs20DSs4DtRcEQQzHXX2MjkP9pwz8y4YACthCr/nRIuP2BH | ||
| S4NnGzmsY34Up+snMDPgudNi7PwrcRyAnKrOHELOwU5RX5N9oMuzqpC0207bSBjF | ||
| mrAQEBy4WyWbLQ6drwIDAQAB | ||
| -----END PUBLIC KEY----- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require_relative 'spec_helper' | ||
|
|
||
| module Aws | ||
| module CloudFront | ||
| describe Signer do | ||
| let(:key_dir) { File.dirname(__FILE__) } | ||
|
|
||
| describe ':hash_algorithm' do | ||
| it 'defaults to SHA1' do | ||
| signer = UrlSigner.new(key_pair_id: 'K', private_key_path: "#{key_dir}/sep_rsa_key") | ||
| expect(signer.instance_variable_get(:@hash_algorithm)).to eq('SHA1') | ||
| end | ||
|
|
||
| it 'accepts SHA1 and SHA256' do | ||
| %w[SHA1 SHA256 sha256].each do |alg| | ||
| expect do | ||
| UrlSigner.new(key_pair_id: 'K', private_key_path: "#{key_dir}/sep_rsa_key", hash_algorithm: alg) | ||
| end.to_not raise_error | ||
| end | ||
| end | ||
|
|
||
| it 'raises on an unsupported hash algorithm' do | ||
| expect do | ||
| UrlSigner.new(key_pair_id: 'K', private_key_path: "#{key_dir}/sep_rsa_key", hash_algorithm: 'SHA384') | ||
| end.to raise_error(ArgumentError, /:hash_algorithm must be one of SHA1, SHA256/) | ||
| end | ||
| end | ||
|
|
||
| describe 'private key validation' do | ||
| it 'accepts a PKCS#8 RSA key' do | ||
| expect do | ||
| UrlSigner.new(key_pair_id: 'K', private_key_path: "#{key_dir}/sep_rsa_key") | ||
| end.to_not raise_error | ||
| end | ||
|
|
||
| it 'accepts a PKCS#8 ECDSA P-256 key' do | ||
| expect do | ||
| UrlSigner.new(key_pair_id: 'K', private_key_path: "#{key_dir}/sep_ecdsa_key") | ||
| end.to_not raise_error | ||
| end | ||
|
|
||
| it 'accepts a SEC1 ECDSA P-256 key' do | ||
| expect do | ||
| UrlSigner.new(key_pair_id: 'K', private_key_path: "#{key_dir}/ecdsa_dummy_key") | ||
| end.to_not raise_error | ||
| end | ||
|
|
||
| it 'raises on an unsupported key type' do | ||
| expect do | ||
| UrlSigner.new(key_pair_id: 'K', private_key_path: "#{key_dir}/sep_dsa_key") | ||
| end.to raise_error(ArgumentError, /unsupported private key type OpenSSL::PKey::DSA/) | ||
| end | ||
|
|
||
| it 'raises on an ECDSA key that is not P-256' do | ||
| key = OpenSSL::PKey::EC.generate('secp384r1').to_pem | ||
| expect do | ||
| UrlSigner.new(key_pair_id: 'K', private_key: key) | ||
| end.to raise_error(ArgumentError, /unsupported ECDSA curve `secp384r1'/) | ||
| end | ||
|
|
||
| it 'raises on an invalid key' do | ||
| expect do | ||
| UrlSigner.new(key_pair_id: 'K', private_key: 'not a key') | ||
| end.to raise_error(ArgumentError, /invalid private key/) | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.