-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat(cloudfront): mutual TLS #36245
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
Open
badmintoncryer
wants to merge
26
commits into
aws:main
Choose a base branch
from
badmintoncryer:mtls
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+38,284
−0
Open
feat(cloudfront): mutual TLS #36245
Changes from 3 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
dd850cd
feat(cloudfront): add support for mutual TLS (mTLS) configuration in …
badmintoncryer 4171d17
add integ
badmintoncryer d5ece7b
update readme
badmintoncryer 9393986
update unit test
badmintoncryer 0b2c955
add validation
badmintoncryer 7ab49a8
update integ
badmintoncryer 4ade6c6
Merge branch 'main' into mtls
badmintoncryer 08f1c7d
feat: add Trust Store for mTLS authentication in CloudFront
badmintoncryer fa6ab9d
fix(cloudfront): update TrustStore creation to use higher-level const…
badmintoncryer ef74c4a
fix(truststore): rename trustStoreName to name and add validation for…
badmintoncryer 80e0ed4
Merge remote-tracking branch 'origin/main' into mtls
badmintoncryer a8a4248
fix(truststore): rename 'name' to 'trustStoreName' for consistency an…
badmintoncryer 590a435
add snapshot
badmintoncryer d474f54
fix(truststore): update validation for trustStoreName length to allow…
badmintoncryer 27454ef
Merge branch 'main' into mtls
badmintoncryer 1032488
Update packages/aws-cdk-lib/aws-cloudfront/README.md
badmintoncryer f866228
fix(cloudfront): enforce HTTPS for mTLS configurations in Distribution
badmintoncryer 5f7eab8
fix(truststore): add validation for S3 key to prevent empty strings
badmintoncryer 7b11d15
fix(distribution): simplify mTLS test cases by removing expected values
badmintoncryer d9f166b
Update packages/aws-cdk-lib/aws-cloudfront/test/trust-store.test.ts
badmintoncryer 4b500e4
feat(cloudfront): add TrustStore L2 construct and integration tests f…
badmintoncryer a2ac411
Merge remote-tracking branch 'cryer/mtls' into mtls
badmintoncryer a492868
Merge branch 'main' into mtls
badmintoncryer 2658292
Update packages/aws-cdk-lib/aws-cloudfront/README.md
badmintoncryer e53cde6
fix(cloudfront): enforce viewerProtocolPolicy for mTLS configuration
badmintoncryer 536c835
Merge branch 'main' into mtls
badmintoncryer 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
20 changes: 20 additions & 0 deletions
20
...ing/framework-integ/test/aws-cloudfront/test/integ.distribution-mtls.assets/ca-bundle.pem
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,20 @@ | ||
| -----BEGIN CERTIFICATE----- | ||
| MIIDPTCCAiWgAwIBAgIUTNWxjW1IQhg/6aMz9pVzGtJ5rKcwDQYJKoZIhvcNAQEL | ||
| BQAwLTEUMBIGA1UEAwwLSW50ZWdUZXN0Q0ExFTATBgNVBAoMDEFXUy1DREstVGVz | ||
| dDAgFw0yNTExMzAwMDE5MzRaGA8yMTI1MTEwNjAwMTkzNFowLTEUMBIGA1UEAwwL | ||
| SW50ZWdUZXN0Q0ExFTATBgNVBAoMDEFXUy1DREstVGVzdDCCASIwDQYJKoZIhvcN | ||
| AQEBBQADggEPADCCAQoCggEBAM1nO3RgHLvnoEHnM38hdMqLJW94mPexvrzb2MeU | ||
| rWMlREMSJMJb+2oyNrgjWLMzTHEyGrXz1xpzylZi/22WofPhlmvlwQWNhh3nPmF4 | ||
| 7lwqREoZE6Sz0qsVRhomCx4iCGk/IhdHW1ykbcQp8pWOG7SDdMtvRJpMd/Cpt6bJ | ||
| YYQlQrlpZOfkkryCDYGEk0mQUsYSY8o5H+qJSs3iqcU1asKKrDz/AtTm5ltXvZWP | ||
| B2dn5WH7Y9jN3G44LBPIm5s66kNOooR1kbn4omiHl6WvEu16bMEYEv/KQpm9Y8iZ | ||
| G2qLnGNn0RukXN6dgWIPAWJ3GHIOPeHsKPhNKVzVQCFyJ08CAwEAAaNTMFEwHQYD | ||
| VR0OBBYEFJt1yzqghFLxRXGou2H59fC+C5CZMB8GA1UdIwQYMBaAFJt1yzqghFLx | ||
| RXGou2H59fC+C5CZMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEB | ||
| AKBpFAAQrnE+uNAOj6y1dSRXCEpEZNywsZsKpBZ24ZXj0a/z5agdImXFGqxDaliP | ||
| 2rNcYiy7b+C4fUNBnzAGnKAnTeP0WBc8V4pkfZOQS4dGnnv0vhjqYBTgOqBr0ahG | ||
| 6eWRWT1PGL8JH/86YxMH6NUp/iIhTJJIB9yp3MrM7aUZcE4nNJ2hYfQkHqCfKgQx | ||
| 2sgyC6r3VE/wJIan42hVkdimBW4h4WuCMniSyabMLz2sG8fPuK/wwgVtUy2NZPdl | ||
| G/lHBgczsWx9+ElIz4oqXi3/Oe+gvMNjMPzk2Y+pzwY8IV8KtoUKpTpdlGs0/LZW | ||
| vudHJyYpz5EStIi478jiQlc= | ||
| -----END CERTIFICATE----- |
20 changes: 20 additions & 0 deletions
20
...g/framework-integ/test/aws-cloudfront/test/integ.distribution-mtls.assets/client-cert.pem
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,20 @@ | ||
| -----BEGIN CERTIFICATE----- | ||
| MIIDMDCCAhigAwIBAgIUfgH8ZDseoSmeNjjfxmCGrtuN20kwDQYJKoZIhvcNAQEL | ||
| BQAwLTEUMBIGA1UEAwwLSW50ZWdUZXN0Q0ExFTATBgNVBAoMDEFXUy1DREstVGVz | ||
| dDAgFw0yNTExMzAwMDE5MzRaGA8yMTI1MTEwNjAwMTkzNFowMTEYMBYGA1UEAwwP | ||
| SW50ZWdUZXN0Q2xpZW50MRUwEwYDVQQKDAxBV1MtQ0RLLVRlc3QwggEiMA0GCSqG | ||
| SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCkHCyPtZpWBdDso4olYpTG64kpBXKySMl0 | ||
| 54tX+U7p3ROnVUIFNoWZBXV/qFhrfqWQgwowfCMKtTrqvHX3tXtRF+PtsKiz+3Mw | ||
| GK167D/v8EqMPxFLhuvcM9cROrJdQhd3DX4fJH97LI8jSWBWH/NWH/GtHmnYDemD | ||
| NdbqGkbRUtHcObGJSWS+n+NFwblnHQZzkpDkOPSQjwaGj+M61UqpaXImG6qIT0el | ||
| 2hZeDLHY1CmsEtFl4leQlLp48TlS5RoP0Bs/3nmlDdEEqBur+pPRHEu/GdvJ6GKX | ||
| K+UHdNTYsvv55k3vOZXvm47HvjYMZEZP2QslASCgS3hV7wqFlUxrAgMBAAGjQjBA | ||
| MB0GA1UdDgQWBBS036TLMcpNSb0HCZy1u61JK1aNWzAfBgNVHSMEGDAWgBSbdcs6 | ||
| oIRS8UVxqLth+fXwvguQmTANBgkqhkiG9w0BAQsFAAOCAQEAWdytMtdQwN/x/JkE | ||
| 8pk8sNHeO/dBwGUETN0FO76JpUwEx+jtlZC+qS/sIFmYvrmSggyDEs1ECIXeV+wS | ||
| Ku1uFYsscZm5Eb9I0izGllm7hrn7iEHRxmuLx9sj3AS4JknSI/k8tQB6r4FrIqDg | ||
| vE5AXAZrVZWZDgF4QGC+W0hIApR58KgRnsR5314Lykxc7YTs2cGz6xWkpUvdYNOC | ||
| Hn4/Xq0lGVS6VDQsu+V7nDYkc41z8MYI/raFn5IeWCjHuqsqC7ubGdUNn13Ng4Ws | ||
| smHEV7OPslLVJBme43OWvhe01S9zVelOHP5uUq4Qx65NU/BWMNpsZbeHtPVMebQ7 | ||
| YdbWrQ== | ||
| -----END CERTIFICATE----- |
28 changes: 28 additions & 0 deletions
28
...ng/framework-integ/test/aws-cloudfront/test/integ.distribution-mtls.assets/client-key.pem
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,28 @@ | ||
| -----BEGIN PRIVATE KEY----- | ||
| MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCkHCyPtZpWBdDs | ||
| o4olYpTG64kpBXKySMl054tX+U7p3ROnVUIFNoWZBXV/qFhrfqWQgwowfCMKtTrq | ||
| vHX3tXtRF+PtsKiz+3MwGK167D/v8EqMPxFLhuvcM9cROrJdQhd3DX4fJH97LI8j | ||
| SWBWH/NWH/GtHmnYDemDNdbqGkbRUtHcObGJSWS+n+NFwblnHQZzkpDkOPSQjwaG | ||
| j+M61UqpaXImG6qIT0el2hZeDLHY1CmsEtFl4leQlLp48TlS5RoP0Bs/3nmlDdEE | ||
| qBur+pPRHEu/GdvJ6GKXK+UHdNTYsvv55k3vOZXvm47HvjYMZEZP2QslASCgS3hV | ||
| 7wqFlUxrAgMBAAECggEAH4gKR9JsxPp5Gf6SHHzEeTPoNqmFUBwMGRoj+9M7BlQj | ||
| 4pLPDJFdOfmCifSeiIjc5tdGreosEXKgz1lGkUGdYAdnE9RNlcdKaoNTUbryzfct | ||
| W6UCfbB+wOB1Aip0+tYoDAfbo8AvfkshdXYzvFiHOJUKqmidjZWeuEcv8+r4kF86 | ||
| XPrlBTqYvCB1pF/z6SLXw1tgThUlI0ZRfjhEVNB5nbNBGBJeO8H/4EvAg3QMMXZz | ||
| amn+MFrBI/cVAQuPzUMwtZqTpUo4KG7VYShuvyxL3bEVveVhByhEUjN6yK/7XAnH | ||
| 0qAjo/yBqF4DGHL+IEJJnsY6wddLIuLqNzKxBJ8SgQKBgQDb/zsEDJBCLfExEea3 | ||
| qXIQ/aEZDKrU5FYrUpMqdHKDuZVAu7faqYrdMNiEEz3Jx33CquLpvYBEiHvt18aN | ||
| 6EHgyyGrcYLhVNvgbY/nVljCoyfDmlsoppb6/IuP5LaKO1cqA4myJ9qUl7SZNVdX | ||
| pvp2kyLD1m1C+R5i2J6dH1rw7wKBgQC+94+26wC9Q7pe1MId2yGrfqmBaIWZzx68 | ||
| iLA6TE5Q5Sh3cnOfcNDdj8S5/kX35Qt8x/1PifMfF95kDCyapcdfJeAEduY3+Ybi | ||
| Rx5jBWMjRhad9Vo1Up7qJ/eSCsdRM4lIHTvz2O79/c4BJpvBtHMLPi3KO6tZDgGN | ||
| 9wiyiVtkRQKBgAL7GlmbsfizlqkLjQzABwOj7CLiwQ3Rajl8DPJuUX7nbNZLtNoJ | ||
| ohANMWHYwOWTBmk0145DOxGyp7s5ST9y/jGFjxc7moJjG/eWhHSl/t3kSA2mccXD | ||
| PBh6g4mXl8GXvD6dfagkUhnhVFkfF+fgI1Sn+bidly1pIrhEJyIJ4rmRAoGBAIK1 | ||
| /J6deCIUC6sBQeUhqogx6F/1ZQ0EYet2O/mLZUelsu8fXdjSZYRh9avBSa8GDbjZ | ||
| Qp+AsvKjactdMeKgeji8OfuUTrwdhZ+4QipQ86yfOrffymEZLkDkHmbODeOcvOip | ||
| afHcmKktYiYTgSUzGFOnubvk38HS/mlnn4Jk1jNpAoGAYjQP4tJzno0mYHwWD8QA | ||
| FfGJKzbt+bAaoAlL08t1gMQU7cw/Ipp8ubHsh1WxpqDw9zkkpABHY7xAej9yziJB | ||
| 1RfuJij8jac94QI4alwXRbZVmbOuPBS5CKJy6bH5dNOKz1lbBZg/UDgksCG+rmCp | ||
| IKwlJgdT4NwgDnpCFPCJtf8= | ||
| -----END PRIVATE KEY----- |
5 changes: 5 additions & 0 deletions
5
...esting/framework-integ/test/aws-cloudfront/test/integ.distribution-mtls.assets/index.html
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 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head><title>mTLS Test</title></head> | ||
| <body><h1>Hello mTLS</h1></body> | ||
| </html> |
76 changes: 76 additions & 0 deletions
76
...mework-integ/test/aws-cloudfront/test/integ.distribution-mtls.assets/mtls-test-handler.ts
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,76 @@ | ||
| /* eslint-disable import/no-extraneous-dependencies */ | ||
| import * as https from 'https'; | ||
| import { S3Client, GetObjectCommand } from '@aws-sdk/client-s3'; | ||
|
|
||
| interface MtlsTestEvent { | ||
| distributionDomainName: string; | ||
| certBucket: string; | ||
| useCert: boolean; | ||
| } | ||
|
|
||
| interface MtlsTestResponse { | ||
| statusCode: number; | ||
| statusMessage: string; | ||
| } | ||
|
|
||
| class CertificateRetrievalError extends Error { | ||
| constructor(message: string) { | ||
| super(message); | ||
| this.name = 'CertificateRetrievalError'; | ||
| } | ||
| } | ||
|
|
||
| export async function handler(event: MtlsTestEvent): Promise<MtlsTestResponse> { | ||
| let cert: string | undefined; | ||
| let key: string | undefined; | ||
|
|
||
| if (event.useCert) { | ||
| const s3 = new S3Client({}); | ||
|
|
||
| // Get client certificate from S3 | ||
| const certObj = await s3.send(new GetObjectCommand({ | ||
| Bucket: event.certBucket, | ||
| Key: 'client-cert.pem', | ||
| })); | ||
| const keyObj = await s3.send(new GetObjectCommand({ | ||
| Bucket: event.certBucket, | ||
| Key: 'client-key.pem', | ||
| })); | ||
|
|
||
| cert = await certObj.Body?.transformToString(); | ||
| key = await keyObj.Body?.transformToString(); | ||
|
|
||
| if (!cert || !key) { | ||
| throw new CertificateRetrievalError('Failed to retrieve client certificate or key from S3'); | ||
| } | ||
| } | ||
|
|
||
| return new Promise((resolve, reject) => { | ||
| const options: https.RequestOptions = { | ||
| hostname: event.distributionDomainName, | ||
| port: 443, | ||
| path: '/index.html', | ||
| method: 'GET', | ||
| rejectUnauthorized: false, // Allow CloudFront's default certificate | ||
| }; | ||
|
|
||
| // Add client certificate if useCert is true | ||
| if (event.useCert && cert && key) { | ||
| options.cert = cert; | ||
| options.key = key; | ||
| } | ||
|
|
||
| const req = https.request(options, (res) => { | ||
| resolve({ | ||
| statusCode: res.statusCode ?? 0, | ||
| statusMessage: res.statusMessage ?? '', | ||
| }); | ||
| }); | ||
|
|
||
| req.on('error', (err) => { | ||
| reject(err); | ||
| }); | ||
|
|
||
| req.end(); | ||
| }); | ||
| } | ||
91 changes: 91 additions & 0 deletions
91
....snapshot/asset.337209f2ea1baf0113f165e9252279f800588ad4c97f8286ce752ec80143c16b/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.