您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“aspnetcore如何使用Let’s Encrypt支持https”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“aspnetcore如何使用Let’s Encrypt支持https”這篇文章吧。
Let’s Encrypt 是一個自動簽發 https 證書的免費項目
Certbot 是 Let’s Encrypt 官方推薦的證書生成客戶端工具
將要簽發證書的域名(如 you.domain.com) 解析到一臺可在外網正常訪問的服務器
my-pc$ ssh user@you.domain.com
這里以 Ubuntu 16.04 為例
各個系統的安裝方式不一樣,可以在官網首頁查閱
my-server$ cat /etc/issue Ubuntu 16.04.2 LTS \n \l my-server$ sudo apt-get update my-server$ sudo apt-get install software-properties-common my-server$ sudo add-apt-repository ppa:certbot/certbot my-server$ sudo apt-get update my-server$ sudo apt-get install certbot my-server$ certbot --version certbot 0.19.0
如果服務器上的 443 端口正在被占用,請先關閉對應的服務進程
否則可能個導致 certbot 運行出錯
my-server$ certbot certonly --------> 開啟命令 Saving debug log to /var/log/letsencrypt/letsencrypt.log How would you like to authenticate with the ACME CA? 1: Spin up a temporary webserver (standalone) 2: Place files in webroot directory (webroot) Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 1 --------> 這里我們選擇 1 standalone 模式 Plugins selected: Authenticator standalone, Installer None Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel): you@gmail.com --------> 輸入你的郵箱創建賬號(只有第一次使用時會出現) Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-2016.pdf. You must agree in order to register with the ACME server at https://acme-v01.api.letsencrypt.org/directory (A)gree/(C)ancel: a --------> 選擇 A 同意 (只有第一次使用時會出現) Would you be willing to share your email address with the Electronic Frontier Foundation, a founding partner of the Let's Encrypt project and the non-profit organization that develops Certbot? We'd like to send you email about EFF and our work to encrypt the web, protect its users and defend digital rights. (Y)es/(N)o: y --------> 選擇 Y 或 N (只有第一次使用時會出現) Please enter in your domain name(s) (comma and/or space separated) (Enter 'c' to cancel): you.domain.com --------> 這里輸入要制作證書的域名 Obtaining a new certificate Performing the following challenges: tls-sni-01 challenge for you.domain.com Waiting for verification... Cleaning up challenges IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/you.domain.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/you.domain.com/privkey.pem Your cert will expire on 2018-01-26. To obtain a new or tweaked version of this certificate in the future, simply run certbot again. To non-interactively renew *all* of your certificates, run "certbot renew" - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le my-server$ ls /etc/letsencrypt/live/you.domain.com/ --------> 證書文件目錄 cert.pem chain.pem fullchain.pem privkey.pem README
看到 IMPORTANT NOTES
下方出現 Congratulations
就表明證書已經成功簽發
可以進入 /etc/letsencrypt/live/you.domain.com/
目錄查看相關生成的文件
默認 standalone 是使用 443 端口,也就是說要停止服務器現在占用 443 端口的進程
我們也可以將其改為使用 80 端口,同樣道理,這時需要停止 80 端口的占用
my-server$ certbot certonly --standalone -n --agree-tos --email you@gmail.com --preferred-challenges http -d you.domain.com
-n
非交互式
--email
指定賬戶
--agree-tos
同意服務協議
安裝 nginx 和插件
my-server$ apt-get install nginx my-server$ apt-get install python-certbot-nginx my-server$ certbot --nginx -d you.domain.com
manual 模式其實和 webroot 類似,主要的區別就是 certbot 自動向 webroot 添加文件的過程,變為你自己手動完成
my-server$ certbot certonly --manual -d you.domain.com Saving debug log to /var/log/letsencrypt/letsencrypt.log Obtaining a new certificate Performing the following challenges: http-01 challenge for you.domain.com NOTE: The IP of this machine will be publicly logged as having requested this certificate. If you're running certbot in manual mode on a machine that is not your server, please ensure you're okay with that. Are you OK with your IP being logged? (Y)es/(N)o: y --------> 選 Y Create a file containing just this data: _Pamo3hOMx37O-KHIioWO1P0hbTLZusEZ2a2iCf7PDQ.8CyQk-SfDMR10nk7DuGBFA4IEpVhm1OySU-nSItD1BE And make it available on your web server at this URL: http://you.domain.com/.well-known/acme-challenge/_Pamo3hOMx37O-KHIioWO1P0hbTLZusEZ2a2iCf7PDQ Press Enter to Continue --------> 你需要保證 http://you.domain.com/.well-known/acme-challenge/_Pamo3hOMx37O-KHIioWO1P0hbTLZusEZ2a2iCf7PDQ 這個 url 返回的結果為 _Pamo3hOMx37O-KHIioWO1P0hbTLZusEZ2a2iCf7PDQ.8CyQk-SfDMR10nk7DuGBFA4IEpVhm1OySU-nSItD1BE (這個數據是隨機的,每次都不一樣) 當你做到后,按下回車鍵繼續 Waiting for verification... Cleaning up challenges IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/you.domain.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/you.domain.com/privkey.pem Your cert will expire on 2018-01-27. To obtain a new or tweaked version of this certificate in the future, simply run certbot again. To non-interactively renew *all* of your certificates, run "certbot renew" - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le
my-server$ certbot certificates
以 nginx 為例
server { listen 80; listen 443 ssl; server_name you.domain.com; ssl_certificate /etc/letsencrypt/live/you.domain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/you.domain.com/privkey.pem; # ... }
同一個頂級域名下的二級域名,一周做多申請 20 個
一個域名一周最多申請 5 次
1 小時最多允許失敗 5 次
請求頻率需要小于 20 次/s
一個 ip 3 小時內最多創建 10 個賬戶
一個賬戶最多同時存在 300 個 pending 的審核
在 certbot 命令后加上 --staging
參數,限制更松一些,但不是正式證書
同一個頂級域名下的二級域名,一周做多申請 30000 個
一個域名一周最多申請 30000 次
1 小時最多允許失敗 60 次
一個 ip 3小時內最多創建 50 個賬戶
openssl pkcs12 -export -out cert.pfx -passout pass:你的密碼 -inkey privkey.pem -in cert.pem -certfile fullchain.pem
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>() .UseKestrel(options => { options.AddServerHeader = false; #if !DEBUG options.ConfigureHttpsDefaults(co => { var cert = new X509Certificate2(File.ReadAllBytes(@"./cert.pfx"), "你的密碼"); co.ServerCertificate = cert; }); #endif }); })
以上是“aspnetcore如何使用Let’s Encrypt支持https”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。