顯示具有 letsencrypt 標籤的文章。 顯示所有文章
顯示具有 letsencrypt 標籤的文章。 顯示所有文章

2017年12月29日 星期五

centos6.2 , tomcat6 , LetsEncrypt


wget https://dl.eff.org/certbot-auto

chmod a+x certbot-auto

certbot-auto certonly --webroot -w /var/lib/tomcat6/webapps -d {DomainName} -m {E-Mail}


cd /etc/letsencrypt/live/{DomainName}

--openssl pkcs12 -export -out bundle.pfx -inkey privkey.pem -in cert.pem -certfile chain.pem -password pass:{PASSWORD}


openssl pkcs12 -export -out /etc/letsencrypt/live/www.vghtc.gov.tw/fullchain_and_key.p12     -in /etc/letsencrypt/live/www.vghtc.gov.tw/fullchain.pem     -inkey /etc/letsencrypt/live/www.vghtc.gov.tw/privkey.pem     -name tomcat


最後真的有效的
openssl pkcs12 -export -in fullchain.pem -inkey privkey.pem -out keystore.p12 -name tomcat -CAfile chain.pem -caname root  //看看能不能上password

keytool -importkeystore -deststorepass cc3fvghtc -destkeypass cc3fvghtc -srckeystore keystore.p12 -destkeystore www.vghtc.gov.tw.jks -srcstoretype pkcs12 -srcstorepass cc3fvghtc -alias tomcat



1202  cp /etc/letsencrypt/live/www.vghtc.gov.tw/www.vghtc.gov.tw.jks /var/lib/tomcat6/


 1232  iptables -I PREROUTING -t nat -p tcp --dport 443 -j REDIRECT --to-port 8443
 1233  iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
 1234  iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 8443 -j ACCEPT
 1242  iptables-save



-------------------------------------
強制改走 https

http://adalf0722.blogspot.tw/2010/12/tomcathttp-80https-443.html

0.先備份web.xml與servel.xml

1.編輯Tomcat安裝目錄conf下的web.xml
  在</welcome-file-list>與</web-app>之間,加入如下的code,然後存檔

<security-constraint>
 <web-resource-collection>
 <web-resource-name>Protected Context</web-resource-name>
 <url-pattern>/*</url-pattern>
 </web-resource-collection>
 <user-data-constraint>
 <transport-guarantee>CONFIDENTIAL</transport-guarantee>
 </user-data-constraint>
 </security-constraint>
2.同樣編輯目錄下的server.xml,確認一下redirectPort是不是已經是443
    <Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="443" />
3.完成,重啟Tomcat一下,就可以試試看囉


https://www.journaldev.com/160/steps-to-configure-ssl-on-tomcat-and-setup-auto-redirect-from-http-to-https


Tomcat Redirect HTTP to HTTPS

So we can access any web application on both HTTP and HTTPS ports. We can set up tomcat to redirect all HTTP request to HTTPS port with some configurations.
  1. In ~TomcatInstallation/conf/server.xml
    For HTTP Connector, set the redirect port to the HTTPS connector port. It will look somewhat like this:
    <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
        <Connector port="8090" maxHttpHeaderSize="8192"
                   maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
                   enableLookups="false" redirectPort="8443" acceptCount="100"
                   connectionTimeout="20000" disableUploadTimeout="true" />
  2. In ~TomcatInstallation/conf/web.xml
    Add below configuration but make sure to add it after all the servlet mapping tags.
    <!-- added by Pankaj for automatic redirect from HTTP to HTTPS -->
    <security-constraint>
    <web-resource-collection>
    <web-resource-name>Entire Application</web-resource-name>
    <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
    <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
    </security-constraint>
Restart the tomcat now and all the HTTP requests will automatically be redirected to HTTPS i.e http://localhost:8080/axis2 will be automatically redirected to https://localhost:8443/axis2
Note: If you don’t want to provide ports in the URLs, then use 80 for HTTP and 443 for HTTPS and in this case you can skip the first step to automatic redirect HTTP requests to HTTPS because it will automatically pick the default port 443.
-------------------------------------
Failed to load keystore type JKS with path jks due to (Permission denied)

把 keystore 搬到 tomcat 家目錄底下(好像在/etc下會看不到 可能是沒有從 root 開始開 read 的關係)

-------------------------------------
https://teddysun.com/153.html

安装完运行yum报错:
Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again
解决办法:
vi /etc/yum.repos.d/epel.repo
编辑[epel]下的baseurl前的#号去掉,mirrorlist前添加#号。正确配置如下:
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

-------------------------------------
http://acman.bluenest.net/wordpress/archives/96