Last active
April 11, 2020 13:26
-
-
Save ad-m/df6d7ad93a0e1a37e0f9 to your computer and use it in GitHub Desktop.
MyDevil.net & Let's Encrypt together
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
# installation | |
set -e | |
set -x | |
mkdir ~/acme-tiny/; # make work dir | |
cd ~/acme-tiny/; # go to work dir | |
wget "https://github.com/diafygi/acme-tiny/raw/master/acme_tiny.py"; # download client | |
openssl genrsa 4096 > account.key; # generate ACME key | |
wget -O - https://letsencrypt.org/certs/lets-encrypt-x1-cross-signed.pem > intermediate.pem | |
# per domain | |
function sign_domain(){ # {domain} {ip} | |
rm -r ~/domains/"$1"/public_python/public/.well-known/ || echo "0"; | |
rm -r ~/acme-tiny/"$1" || echo "0"; | |
/usr/local/bin/python /usr/local/devil/devil/bin/devil.pyc ssl www del "$2" "$1" || echo "0"; # delete old keys | |
mkdir ~/acme-tiny/"$1" ; # make dir for domain data | |
openssl genrsa 4096 > ~/acme-tiny/"$1"/domain.key; # make key for domain | |
openssl req -new -sha256 -key ~/acme-tiny/"$1"/domain.key -subj "/CN=$1" > ~/acme-tiny/"$1"/domain.csr # generate CSR | |
mkdir -p ~/domains/"$1"/public_python/public/.well-known/acme-challenge/; # make challenge dir | |
python acme_tiny.py --account-key ./account.key --csr ~/acme-tiny/"$1"/domain.csr --acme-dir ~/domains/"$1"/public_python/public/.well-known/acme-challenge/ > ~/acme-tiny/"$1"/signed.crt; # get cert | |
cat ~/acme-tiny/"$1"/signed.crt intermediate.pem > ~/acme-tiny/"$1"/chained.pem; # attach Let's Encrypt cert to domain cert | |
/usr/local/bin/python /usr/local/devil/devil/bin/devil.pyc ssl www add "$2" ~/acme-tiny/"$1"/chained.pem ~/acme-tiny/"$1"/domain.key "$1"; # install cert | |
rm -r ~/domains/"$1"/public_python/public/.well-known/; # delete challenges directory; | |
}; | |
sign_domain "kosciol.pilnujemy.info" "91.185.185.211"; |
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
The MIT License (MIT) | |
Copyright (c) 2015 Adam Dobrawy | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all | |
copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
SOFTWARE. | |
@mikes01: Use
openssl req -new -sha256 -key domain.key -subj "/" -reqexts SAN -config <(cat /etc/ssl/openssl.cnf <(printf "[SAN]\nsubjectAltName=DNS:yoursite.com,DNS:www.yoursite.com")) > domain.csr
lets-encrypt-x1-cross-signed.pem
is now retired and should bre replaced with lets-encrypt-x3-cross-signed.pem
(I've tested it).
Source: https://letsencrypt.org/certificates/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Thanks a lot for this script. It works perfect for non-www domains. Have you tried to generate ssl cert for www.domain.com and domain.com? I can sign certificate only for domain.com and I get untrusted warnnig when I go to www.domain.com