簡體   English   中英

Apache WebServer + Tomcat + Spring + Https

[英]Apache WebServer + Tomcat + Spring + Https

我有一個在http上運行的應用程序,然后我嘗試通過https創建登錄頁面。 早期的apache web服務器用於通過ajp協議將請求轉發給tomcat,后者是一名注冊工作者。 現在我在/etc/apache2/crt添加了一個密鑰和證書,即ssl.keyssl.crt 其中還有一個certificate.csr文件。 用於上述證書生成的命令來自http://www.akadia.com/services/ssh_test_certificate.html我還沒有完成第6步,因為在/etc/apache2/sites-available有兩個文件: defaultdefault-ssl 我在default-ssl更改了兩行:

SSLCertificateFile    /etc/apache2/crt/certificate.csr
SSLCertificateKeyFile /etc/apache2/crt/ssl.key

我還更改了tomcat的server.xml以在post 8446接收https:

<Connector port="8446" protocol="HTTP/1.1" SSLEnabled="true"
          maxThreads="150" scheme="https" secure="true"
          clientAuth="false" sslProtocol="TLS" 
          keystoreFile="/etc/apache2/crt/ssl"
          keystorePass="password"/>

我還更改了web.xml ,它現在另外包含:

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Secure Login</web-resource-name>
        <url-pattern>/login/*</url-pattern>
     <!--   <url-pattern>/other/secure/stuff/*</url-pattern> -->
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>

我試過curl -Iv https://localhostcurl -Iv https://localhost:8446但是出現以下錯誤:

About to connect() to localhost port 8446 (#0)
*   Trying 127.0.0.1... Connection refused
* couldn't connect to host
* Closing connection #0
curl: (7) couldn't connect to host

請讓我知道如何實現這一目標。

SSLCertificateFile應該指向你的ssl.crt文件,而不是ssl.csr (只有提交給你的證書頒發機構才能申請證書......之后,CSR根本ssl.csr )。

如果你有Apache httpd執行你的SSL終止(這就是為什么你會有SSLCertificateFile和其他指令),那么你不需要在Tomcat中進行任何額外的設置來處理CONFIDENTIAL通信。

如果要將Tomcat配置為接受HTTPS通信,則/etc/apache2/crt/ssl文件需要是Java密鑰庫,而不是Apache httpd使用的裸證書文件。 Java Keystores是更復雜的野獸,需要使用Java的keytool程序來操作。

我強烈建議您閱讀Tomcat的SSL Howto ,它為您提供有關如何正確設置密鑰庫並在Tomcat中配置它的分步說明。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM