Apache Tomcat Sunucusunda HTTPS veya SSL'yi doğru şekilde etkinleştirmek için Adım Adım kılavuz – Bağlantı Noktası 8443
Yayınlanan: 2021-04-03Apache Tomcat'i kullanmaya başlayalı neredeyse 12 yıl oldu. 1. sınıf projemi yaptığımda, Tomcat sürüm 1.x olduğuna inanıyorum. Şimdi zaten 8.0 sürümünde. Günlük iş hayatımda çoğunlukla Tomcat Server ile iletişim halinde oldum, onsuz yaşayamam.
Crunchify'da Apache Tomcat hakkında yaklaşık 40 makale yayınladık. Eğitimin çoğunda sunucuyu, server.xml dosyasında yapılandırılmış varsayılan bağlantı noktası olan 8080 numaralı bağlantı noktasında çalıştırdım.
Bu eğitimde how to enable HTTPS/SSL on Apache Tomcat Server ilişkin tüm adımları ayrıntılı olarak inceleyeceğiz.
Başlayalım:
Aşama 1. Anahtar Deposu Oluştur
keytool : anahtar ve sertifika yönetim aracı olan keytool komutunu kullanarak güvenli anahtar üreteceğiz.
Emretmek:
|
1 2 3 4 |
bash - 3.2 $ pwd / Users / Shared bash - 3.2 $ keytool - genkey - alias crunchify - keyalg RSA - keystore / Users / Shared / crunchify . keystore |
Dosya /Users/Shared klasörü altında oluşturulacaktır.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
bash - 3.2 $ keytool - genkey - alias crunchify - keyalg RSA - keystore / Users / Shared / crunchify . keystore Enter keystore password : Re - enter new password : What is your first and last name ? [ Unknown ] : App Shah What is the name of your organizational unit ? [ Unknown ] : Crunchify , LLC What is the name of your organization ? [ Unknown ] : Crunchify What is the name of your City or Locality ? [ Unknown ] : New York City What is the name of your State or Province ? [ Unknown ] : NY What is the two - letter country code for this unit ? [ Unknown ] : US Is CN = App Shah , OU = "Crunchify, LLC" , O = Crunchify , L = New York City , ST = NY , C = US correct ? [ no ] : yes Generating 2 , 048 bit RSA key pair and self - signed certificate ( SHA256withRSA ) with a validity of 90 days for : CN = App Shah , OU = "Crunchify, LLC" , O = Crunchify , L = New York City , ST = NY , C = US |
Mac OS X kullanıyorum, bu nedenle Windows kullanıyorsanız yolunuzu buna göre değiştirin. 123456 şifresini kullandım.

Adım 2. Kendinden İmzalı Sertifika İmzalama İsteği Oluşturun
|
1 2 |
bash - 3.2 $ keytool - certreq - keyalg RSA - alias crunchify - file crunchify . csr - keystore crunchify . keystore Enter keystore password : |
Şifreyi girin: 123456
Aşama 3. İlk önce Tomcat'in HTTP üzerinden 8080 numaralı bağlantı noktasında çalıştığını kontrol edelim.
Tomcat sunucusunu şu komutu kullanarak Start : <tomcat_home>/bin/ startup.sh .
Doğru Tomcat yolu konumunda olduğunuzdan emin olun.
|
1 2 3 4 5 6 7 8 9 10 11 |
bash - 3.2 # pwd / Users / Shared / apache - tomcat - 9.0.30 / bin bash - 3.2 $ . / startup . sh Using CATALINA_BASE : / Users / Shared / apache - tomcat - 9.0.30 Using CATALINA_HOME : / Users / Shared / apache - tomcat - 9.0.30 Using CATALINA_TMPDIR : / Users / Shared / apache - tomcat - 9.0.30 / temp Using JRE_HOME : / Library / Java / JavaVirtualMachines / jdk - 13.0.1.jdk / Contents / Home Using CLASSPATH : / Users / Shared / apache - tomcat - 9.0.30 / bin / bootstrap . jar : / Users / Shared / apache - tomcat - 9.0.30 / bin / tomcat - juli . jar Tomcat started . |
Sunucunun çalışır durumda olduğundan emin olmak için URL'ye basın: http://localhost:8080 .

Adım-4. Şimdi HTTPS üzerinden 8443 numaralı bağlantı noktasındaki Tomcat örneğini kontrol edin.
- Şimdi 8443 numaralı bağlantı noktasını (HTTPS/SSL URL'si) kontrol edin.
- Hit URL:
https://localhost:8443 - Hata mesajını görmelisiniz. Sayfa hiç yüklenmemelidir.

Adım 5. /conf/server.xml dosyasını güncelleyin
Yukarıda anahtar deposu ve sertifika imzalama talebi oluşturduğumuz için, Tomcat'e bunu kullanmasını söylememiz gerekiyor.
-
<tomcat_home>/conf/klasöründe bulunanserver.xmldosyasını açın ve ayarları değiştirin. - Bizim durumumuzda
/Users/Shared/apache-tomcat-9.0.30/confklasörü.
Aşağıdaki bölümü doğrudan server.xml dosyasına ekleyin:

|
1 2 3 4 5 |
< Connector port = "8443" protocol = "HTTP/1.1" SSLEnabled = "true" maxThreads = "150" scheme = "https" secure = "true" keystoreFile = "/Users/Shared/crunchify.keystore" keystorePass = "123456" clientAuth = "false" sslProtocol = "TLS" sslVerifyClient = "optional" sslEnabledProtocols = "TLSv1.2,TLSv1.1,SSLv2Hello" / > |
- Burada
Step-1kullandığım şifre123456. - Protokol: HTTP/1.1

Dosyayı kaydet. Ardından Tomcat Sunucusunu durdurup başlatacağız.
Adım-6. Apache Tomcat'i Durdurun ve Başlatın.
- bash-3.2$ /Kullanıcılar/Paylaşılan/apache-tomcat-9.0.30/bin/shutdown.sh
- bash-3.2$ /Kullanıcılar/Paylaşılan/apache-tomcat-9.0.30/bin/startup.sh
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
bash - 3.2 $ / Users / Shared / apache - tomcat - 9.0.30 / bin / shutdown . sh Using CATALINA_BASE : / Users / Shared / apache - tomcat - 9.0.30 Using CATALINA_HOME : / Users / Shared / apache - tomcat - 9.0.30 Using CATALINA_TMPDIR : / Users / Shared / apache - tomcat - 9.0.30 / temp Using JRE_HOME : / Library / Java / JavaVirtualMachines / jdk - 13.0.1.jdk / Contents / Home Using CLASSPATH : / Users / Shared / apache - tomcat - 9.0.30 / bin / bootstrap . jar : / Users / Shared / apache - tomcat - 9.0.30 / bin / tomcat - juli . jar NOTE : Picked up JDK_JAVA_OPTIONS : -- add - opens = java . base / java . lang = ALL - UNNAMED -- add - opens = java . base / java . io = ALL - UNNAMED -- add - opens = java . rmi / sun . rmi . transport = ALL - UNNAMED bash - 3.2 $ / Users / Shared / apache - tomcat - 9.0.30 / bin / startup . sh Using CATALINA_BASE : / Users / Shared / apache - tomcat - 9.0.30 Using CATALINA_HOME : / Users / Shared / apache - tomcat - 9.0.30 Using CATALINA_TMPDIR : / Users / Shared / apache - tomcat - 9.0.30 / temp Using JRE_HOME : / Library / Java / JavaVirtualMachines / jdk - 13.0.1.jdk / Contents / Home Using CLASSPATH : / Users / Shared / apache - tomcat - 9.0.30 / bin / bootstrap . jar : / Users / Shared / apache - tomcat - 9.0.30 / bin / tomcat - juli . jar Tomcat started . |
Adım-7. HTTPS URL'sini ve sertifikayı kontrol edin: https://localhost:8443
Şimdi sayfanızın başarıyla yüklendiğini kontrol etmek için HTTPS güvenli URL'sine tekrar basın.
Krom:
- Varsayılan olarak
Chrome Blocks all insecure HTTPSsitelerinin yüklenmesini engeller. - Localhost'tan yüklenen kaynaklar için geçersiz sertifikalar yüklemek üzere
Chrome flagetkinleştirin
- Chrome'a git
- Sekmeyi Aç
- tür:
chrome://flags/#allow-insecure-localhost - Açılır menüden bayrağı etkinleştir
- Chrome'u yeniden başlat

Safari ve Mozilla Firefox:
-
Accept invalid certificate erroredin ve siteyi ziyaret edin.
8443 numaralı bağlantı noktasında HTTPS üzerinden Apache Tomcat sayfasının yüklendiğini görmelisiniz

Hepiniz hazırsınız. red padlock fark ettiniz mi? Merak etme. Verisign veya Comodo'dan SSL sertifikası satın almadık.
Üretim ortamında bu kırmızı çarpı işaretini göremeyebilirsiniz.
Tarayıcıda sertifikaya tıklayın ve varsayılan kendinden imzalı sertifikamız
valid for 90olmalıdır.

Bonus noktası:
Komut keytool kullanarak cert content nasıl kontrol edebilirsiniz?
|
1 |
bash - 3.2 # keytool -list -keystore /Users/<username>/crunchify.keystore |
Sonuç:
|
1 2 3 4 5 6 7 8 9 10 11 12 |
bash - 3.2 $ keytool - list - keystore / Users / Shared / crunchify . keystore Enter keystore password : Keystore type : PKCS12 Keystore provider : SUN Your keystore contains 1 entry crunchify , Apr 24 , 2020 , PrivateKeyEntry , Certificate fingerprint ( SHA - 256 ) : 9D : 26 : 77 : E0 : E8 : 79 : 5B : 46 : 57 : 64 : 04 : 95 : B8 : 22 : 9C : E2 : 9F : A4 : 82 : CB : 01 : B5 : 80 : 62 : 75 : 90 : 48 : 27 : 5F : 60 : CB : C8 bash - 3.2 $ |
