转载请注明出处:http://blog.csdn.net/sunyujia/
使用Openssl为Tomcat配置SSL(双向认证) 见http://blog.csdn.net/sunyujia/archive/2008/10/05/3017405.aspx
单向认证比较简单一个批处理就可以搞定了
读者直接执行如下批处理demo.bat即可
- @echo off
- echo.
- echo 单向SSL验证 TOMCAT_HOME/conf/server.xml文件配置示例
- echo.
- echo My Blog:ht^tp://blog.csdn.net/sunyujia/
- echo.
- echo ^<Connector port="443"
- echo protocol="HTTP/1.1"
- echo SSLEnabled="true"
- echo maxThreads="150"
- echo scheme="https"
- echo secure="true"
- echo clientAuth="false"
- echo sslProtocol="TLS"
- echo enableLookups="false"
- echo keystorePass="密码"
- echo keystoreFile="tomcat.keystore"
- echo useBodyEncodingForURI="true"/^>
- echo.
- echo 下面生成tomcat.keystore到TOMCAT_HOME
- echo.
- echo Set shell = CreateObject("Shell.Application") >tmp.vbs
- echo Set selFolder = shell.BrowseForFolder(0, "选择Tomcat目录 http://blog.csdn.net/sunyujia/", 0, ssfDRIVES) >>tmp.vbs
- echo Set selFolderItem = selFolder.Self >>tmp.vbs
- echo wscript.echo selFolderItem.Path >>tmp.vbs
- echo.
- for /f "delims=" %%i in ('cscript /nologo tmp.vbs') do set TOMCAT_HOME=%%i
- echo.
- del tmp.vbs
- echo 密码至少6位 稍后询问主密码是否与keystore密码相同输入y , server.xml文件中keystorePass选项配置此密码.
- echo 输入过程中询问信息是否正确时输入y表示正确
- echo.
- if exist tomcat.keystore (del tomcat.keystore)
- keytool -genkey -alias tomcat -keyalg RSA -keysize 1024 -validity 3650 -keystore tomcat.keystore
- echo.
- echo 文件已生成
- echo.
- echo 移动当前目录下的tomcat.keystore到%TOMCAT_HOME%
- move tomcat.keystore "%TOMCAT_HOME%/tomcat.keystore"
- echo.
- pause