-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Enable creation of strong names for .NET assemblies. #643
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e4598c8
Enable creation of strong names for .NET assemblies.
mpiroc 8be41f6
Address feedback from code review.
mpiroc ec72837
Merge branch 'pirocchi/init' into pirocchi/snk
mpiroc 2e7e0ea
Restore unintentionally removed newline.
mpiroc a575a2a
Merge branch 'pirocchi/init' into pirocchi/snk
mpiroc b59db47
Merge changes to fetch-dotnet-snk.sh from jsii repo.
mpiroc 2ba98d8
feat(aws-dynamodb): Support server-side encryption (#684)
jungseoklee 34655f2
Add `cdk init` template for .NET, and re-enable .NET targets (#617)
mpiroc 884740d
Merge branch 'master' into pirocchi/snk
2a90730
Merge branch 'pirocchi/init' into pirocchi/snk
rix0rrr 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 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 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,61 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
# This script retrieves the .snk file needed to create strong names for .NET assemblies. | ||
|
||
function echo_usage() { | ||
echo "USAGE: Set the following environment variables, then run ./fetch-dotnet-snk.sh with no arguments." | ||
echo -e "\tDOTNET_STRONG_NAME_ENABLED=true" | ||
echo -e "\tDOTNET_STRONG_NAME_ROLE_ARN=<ARN of a role with access to the secret. You must have iam:AssumeRole permissions for this role.>" | ||
echo -e "\tDOTNET_STRONG_NAME_SECRET_REGION=<The AWS region (i.e. us-east-2) in which in the secret is stored.>" | ||
echo -e "\tDOTNET_STRONG_NAME_SECRET_ID=<The name (i.e. production/my/key) or ARN of the secret containing the .snk file.>" | ||
} | ||
|
||
if [ -z ${DOTNET_STRONG_NAME_ENABLED:-} ]; then | ||
echo "Environment variable DOTNET_STRONG_NAME_ENABLED is not set. Skipping strong-name signing." | ||
exit 0 | ||
fi | ||
|
||
echo "Retrieving SNK..." | ||
|
||
apt update -y | ||
apt install jq -y | ||
|
||
if [ -z ${DOTNET_STRONG_NAME_ROLE_ARN:-} ]; then | ||
echo "Strong name signing is enabled, but DOTNET_STRONG_NAME_ROLE_ARN is not set." | ||
echo_usage | ||
exit 1 | ||
fi | ||
|
||
if [ -z ${DOTNET_STRONG_NAME_SECRET_REGION:-}]; then | ||
echo "Strong name signing is enabled, but DOTNET_STRONG_NAME_SECRET_REGION is not set." | ||
echo_usage | ||
exit 1 | ||
fi | ||
|
||
if [ -z ${DOTNET_STRONG_NAME_SECRET_ID:-} ]; then | ||
echo "Strong name signing is enabled, but DOTNET_STRONG_NAME_SECRET_ID is not set." | ||
echo_usage | ||
exit 1 | ||
fi | ||
|
||
ROLE=$(aws sts assume-role --region ${DOTNET_STRONG_NAME_SECRET_REGION:-} --role-arn ${DOTNET_STRONG_NAME_ROLE_ARN:-} --role-session-name "jsii-dotnet-snk") | ||
export AWS_ACCESS_KEY_ID=$(echo $ROLE | jq -r .Credentials.AccessKeyId) | ||
export AWS_SECRET_ACCESS_KEY=$(echo $ROLE | jq -r .Credentials.SecretAccessKey) | ||
export AWS_SESSION_TOKEN=$(echo $ROLE | jq .Credentials.SessionToken) | ||
|
||
SNK_SECRET=$(aws secretsmanager get-secret-value --region ${DOTNET_STRONG_NAME_SECRET_REGION:-} --secret-id ${DOTNET_STRONG_NAME_SECRET_ID:-}) | ||
TMP_DIR=$(mktemp -d) | ||
TMP_KEY="$TMP_DIR/key.snk" | ||
echo $SNK_SECRET | jq -r .SecretBinary | base64 --decode > $TMP_KEY | ||
|
||
for PACKAGE_PATH in packages/@aws-cdk/*; do | ||
JSII_PROPERTY=$(cat "$PACKAGE_PATH/package.json" | jq -r .jsii) | ||
if [ -z $JSII_PROPERTY ]; then | ||
continue | ||
fi | ||
|
||
cp $TMP_KEY $PACKAGE_PATH | ||
done | ||
|
||
rm -rf $TMP_DIR |
This file contains 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 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 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 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
File renamed without changes.
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of copying this file everywhere, maybe the .NET build can consult an environment variable for it's location?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another issue with using an environment variable is: How would it be set? The temporary directory is created by
fetch-dotnet-snk.sh
, butbuild.sh
is a sibling process offetch-dotnet-snk.sh
, not a descendant. A process can't modify its parent's environment variables.