daily pastebin goal
17%
SHARE
TWEET

Untitled

a guest Feb 16th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # Fetch available updates, upgrade current packages and install updates
  4. sudo apt-get update
  5. sudo apt-get upgrade --assume-yes
  6. sudo apt-get dist-upgrade --assume-yes
  7.  
  8. # Install pip, awscli, nodejs, npm and json
  9. sudo apt install python-pip --assume-yes
  10. pip install awscli --upgrade --user
  11. sudo apt install --assume-yes npm nodejs-legacy
  12. sudo npm install -g json
  13.  
  14.  
  15. # Generate the TLS Certificate and drop it in the right place for Tomcat.
  16. cd /opt/bitnami/apache2/conf
  17. printf "[req]\nreq_extensions = v3_req\ndistinguished_name = req_distinguished_name\n\n[ req_distinguished_name ]\n\n[v3_req]\nsubjectAltName = @alt_names\n\n[alt_names]\nDNS.1 = DNS_NAME_PLACEHOLDER\n" > ssl.conf
  18. sudo openssl req -nodes -newkey rsa:2048 -days 365 -keyout server.key -out server.csr -subj "/O=Example/CN=DNS_NAME_PLACEHOLDER" -config ssl.conf
  19.  
  20. certificateArn=$(~/.local/bin/aws acm-pca issue-certificate --certificate-authority-arn PCA_ARN_PLACEHOLDER --csr file://server.csr --signing-algorithm "SHA256WITHRSA" --validity Value=365,Type="DAYS" --region eu-west-1 | json CertificateArn)
  21.  
  22. # Sometimes it may take a few seconds before the certificat becomes available.
  23. sleep 10
  24.  
  25. fullCertificate=$(~/.local/bin/aws acm-pca get-certificate --certificate-authority-arn PCA_ARN_PLACEHOLDER --certificate-arn $certificateArn --region eu-west-1)
  26. echo $fullCertificate | json Certificate | sudo tee server.crt
  27. echo $fullCertificate | json CertificateChain | sudo tee  server-ca.crt
  28.  
  29. # Restart the server to ensure certificates are picked up.
  30. sudo shutdown -r now
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top