gusto2

Apache HTTP SSL certificate with Tomcat AJP

Nov 18th, 2013
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.69 KB | None | 0 0
  1. http://www.zeitoun.net/articles/configure-mod_proxy_ajp-with-tomcat/start
  2. You just have to create the AJP connector in the conf/server.xml file like that:
  3. <Connector port="8009" enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
  4.  
  5. http://www.zeitoun.net/articles/client-certificate-x509-authentication-behind-reverse-proxy/start
  6. Between Apache HTTP and Tomcat AJP
  7.  
  8.  
  9. <IfDefine SSL>
  10. <IfDefine !NOSSL>
  11.  
  12. ProxyRequests On
  13. ProxyVia On
  14.  
  15. ProxyPreserveHost On
  16.  
  17. Listen 1979
  18. NameVirtualHost *:1979
  19. <VirtualHost *:1979>
  20. ServerName localhost
  21.  
  22. ErrorLog /var/log/apache2/1979.error.log
  23. CustomLog /var/log/apache2/1979.access.log combined
  24.  
  25. SSLEngine On
  26. SSLCertificateFile /etc/apache2/ssl/mycert.crt
  27. SSLCertificateKeyFile /etc/apache2/ssl/mycert.key
  28.  
  29. SSLCACertificateFile /etc/apache2/ssl/client-accepted-ca-chain.crt
  30. SSLVerifyClient optional
  31. SSLVerifyDepth 2
  32.  
  33. # this option is mandatory to force apache to forward the client cert data to tomcat
  34. SSLOptions +ExportCertData
  35.  
  36. <Proxy *>
  37. AddDefaultCharset Off
  38. Order deny,allow
  39. Allow from all
  40. </Proxy>
  41.  
  42. ProxyPass / ajp://localhost:8009/
  43. ProxyPassReverse / ajp://localhost:8009/
  44.  
  45. </VirtualHost>
  46.  
  47. Generic Proxy with client certificate header
  48. Listen 1981
  49. NameVirtualHost *:1981
  50. <VirtualHost *:1981>
  51. ServerName localhost
  52.  
  53. ErrorLog /var/log/apache2/1981.error.log
  54. CustomLog /var/log/apache2/1981.access.log combined
  55.  
  56. # activate HTTPS on the reverse proxy
  57. SSLEngine On
  58. SSLCertificateFile /etc/apache2/ssl/mycert.crt
  59. SSLCertificateKeyFile /etc/apache2/ssl/mycert.key
  60.  
  61. # activate the client certificate authentication
  62. SSLCACertificateFile /etc/apache2/ssl/client-accepted-ca-chain.crt
  63. SSLVerifyClient require
  64. SSLVerifyDepth 2
  65.  
  66. <Proxy *>
  67. AddDefaultCharset Off
  68. Order deny,allow
  69. Allow from all
  70. </Proxy>
  71.  
  72. # initialize the special headers to a blank value to avoid http header forgeries
  73. RequestHeader set SSL_CLIENT_S_DN ""
  74. RequestHeader set SSL_CLIENT_I_DN ""
  75. RequestHeader set SSL_SERVER_S_DN_OU ""
  76. RequestHeader set SSL_CLIENT_VERIFY ""
  77.  
  78. <Location />
  79. # add all the SSL_* you need in the internal web application
  80. RequestHeader set SSL_CLIENT_S_DN "%{SSL_CLIENT_S_DN}s"
  81. RequestHeader set SSL_CLIENT_I_DN "%{SSL_CLIENT_I_DN}s"
  82. RequestHeader set SSL_SERVER_S_DN_OU "%{SSL_SERVER_S_DN_OU}s"
  83. RequestHeader set SSL_CLIENT_VERIFY "%{SSL_CLIENT_VERIFY}s"
  84.  
  85. ProxyPass http://localhost:50161/
  86. ProxyPassReverse http://localhost:50161/
  87. </Location>
  88. </VirtualHost>
  89.  
  90.  
  91. </IfDefine>
  92. </IfDefine>
  93.  
  94.  
  95. Tomcat SSL
  96. - create conf/tomcat.jks with a valid server key
  97. - copy cert login module into tomcat lib
  98. - http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html
  99. - import belg root cert
  100.  
  101. server.xml
  102. <Connector
  103. port="9443" maxThreads="20"
  104. scheme="https" secure="true" SSLEnabled="true"
  105. keystoreFile="./conf/tomcat.jks" keystorePass="apogado"
  106. truststoreFile="./conf/tomcat.jks" truststorePass="apogado"
  107. clientAuth="true" sslProtocol="TLS"/>
  108.  
  109. <Realm
  110. className="org.apache.catalina.realm.JAASRealm"
  111. appName="CertLoginRealm"
  112. userClassNames="com.apogado.midoffice.auth.CertUserPrincipal"
  113. roleClassNames="com.apogado.midoffice.auth.CertRolePrincipal" />
  114.  
  115. http://www.byteslounge.com/tutorials/jaas-authentication-in-tomcat-example
  116. Tomcat login module
  117. C:\programs\tomcat-6.0.37>set JAVA_OPTS= "-Djava.security.auth.login.config==$CA
  118. TALINA_BASE/conf/jaas.config"
  119.  
  120. conf/jaas.config:
  121. CertLoginRealm {
  122. com.apogado.midoffice.auth.CertLoginModule required;
  123. };
Advertisement
Add Comment
Please, Sign In to add comment