跳到主要內容

發表文章

目前顯示的是有「ssl」標籤的文章

Let'sEncrypt with Spring-boot Https

網路管理基礎 Route53 與網路管理基本概念 EC2 Https 設定 AWS 綁定 Domain Route53 建立 Hosted Zones, 自己申請的 Domain (my-domain.me) Route53 Hosted Zones 建立 Record (my-domain.me), 綁定 EC2 Let’sEncrypt Certificate 申請 1. 安裝 certbot 工具 $ git clone https://github.com/certbot/certbot.git $ cd certbot $ ./certbot-auto 2. 透過 certbot 的 plugin 申請 certificate $ ./certbot-auto certonly —a standalone -d my-domain.me —email someone@gmail.com 在流程中, 需要回答一些問題, LetsEncrypt 會發送 request 去驗證 my-domain.me 這個 domain 3. 使用 openssl 將 letsEncrypt 的 key 產生 ssl 這是 os 環境 letsencrypt 的預設目錄路徑 $ cd /etc/letsencrypt/live/my-domain.me 把 letEncrypt 給你的 private key 產生 ssl 憑證 $ openssl pkcs12 -export -in fullchain.pem \ -inkey privkey.pem \ -out keystore.p12 -name tomcat \ -CAfile chain.pem \ -caname root 把生成的 ssl 憑證, 放到 spring-boot 專案底下的 resouces $ cp keystone.p12 ~/my-web-project/main/resources/ 4. 設定 application-prod.yml server: port: 8443...

Spring boot Https 設定

1. 產生 SSL certificate keytool -genkey -alias tomcat -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore keystore.p12 -validity 3650 Enter keystore password: Re-enter new password: What is your first and last name? [Unknown]: jerry What is the name of your organizational unit? [Unknown]: td What is the name of your organization? [Unknown]: com What is the name of your City or Locality? [Unknown]: taipei What is the name of your State or Province? [Unknown]: taiwan What is the two-letter country code for this unit? [Unknown]: tw Is CN=jarvis, OU=td, O=urad, L=taipei, ST=taiwan, C=tw correct? [no]: yes 這個 certificate 是 self-signed certificate 沒有經過第三方認證, 所以沒有公信力, 正式上線會在瀏覽器看到 連線不被信任 要有公信力的 certificate 最簡單的是 Lets Encrypt , 其他就是花一些錢找簽發 certificate 的組織 2. Enable HTTPS in Spring Boot Spring Boot 內建的 tomcat 預設 http 是 8080, Spring Boot 可以設定 http 跟 https, 但沒辦法同時存在這兩個設定, 如果要同時存在兩種 connection, 建議依照 文件 建議設定 https, 再透過 programmatically 去設定 http 會比較容易。 相關範例可以參考 : https://...