-
Notifications
You must be signed in to change notification settings - Fork 39
creds_setup.sh does not work on Windows #64
Description
There are a couple of lines of bash code that does not work on Windows:
-
timestampvariable on line 41 includes colon(":"). This is used later when writing openssl keys to a disk location. The problem is that colon is not allowed as part of a file or folder name in Windows. See below for the code:
compose-services/creds_setup.sh
Lines 40 to 55 in 4b9509f
# make directories for temporary credentials timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ") # generate private and public key for fence yearMonth="$(date +%Y-%m)" if [[ ! -d ./fenceJwtKeys ]] || ! (ls ./fenceJwtKeys | grep "$yearMonth" > /dev/null 2>&1); then echo "Generating fence OAUTH key pairs under Secrets/fenceJwtKeys" mkdir -p fenceJwtKeys mkdir -p fenceJwtKeys/${timestamp} openssl genpkey -algorithm RSA -out fenceJwtKeys/${timestamp}/jwt_private_key.pem \ -pkeyopt rsa_keygen_bits:2048 openssl rsa -pubout -in fenceJwtKeys/${timestamp}/jwt_private_key.pem \ -out fenceJwtKeys/${timestamp}/jwt_public_key.pem chmod -R a+rx fenceJwtKeys fi -
SUBJvariable on line 82 is not preserved as defined when provided as parameter input toopenssl req -sbjon line 84. For this code to work, theSUBJstring value has to be revised toSUBJ="//countryName=US\stateOrProvinceName=IL\localityName=Chicago\organizationName=CDIS\organizationalUnitName=PlanX\commonName=$commonName\emailAddress=cdis@uchicago.edu". Here is a related discussion on StackOverflow.
See below for the code:
compose-services/creds_setup.sh
Lines 77 to 84 in 4b9509f
if ! [[ -f openssl.cnf && -f ca.pem && -f ca-key.pem ]]; then echo "Generating a local certificate authority, and TLS certificates under Secrets/TLS/" # erase old certs if they exist /bin/rm -rf service.key service.crt commonName=${1:-localhost} SUBJ="/countryName=US/stateOrProvinceName=IL/localityName=Chicago/organizationName=CDIS/organizationalUnitName=PlanX/commonName=$commonName/emailAddress=cdis@uchicago.edu" openssl req -new -x509 -nodes -extensions v3_ca -keyout ca-key.pem \ -out ca.pem -days 365 -subj $SUBJ $OPTS
I've tweaked the two lines mentioned above to get the script work using Git Bash on my machine running on Windows 10 Home.
It would be helpful if the script is modified to accommodate Windows users or at least that this repo's README.md mentions that the script is meant to be run on Linux/MacOS.