> For the complete documentation index, see [llms.txt](https://doc.skill.or.kr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.skill.or.kr/apache-ssl-to-tomcat-ssl.md).

# 가비아 Apache SSL 보안인증서 to Tomcat SSL 보안인증서로 변경

{% embed url="<https://paypal.me/shop2002>" %}
donation
{% endembed %}

{% hint style="info" %}
**2022년 NHN Cloud&#x20;**<mark style="color:red;">**무료**</mark>**&#x20;교육일정** : <https://doc.skill.or.kr/2022-NHN-Cloud-Education>
{% endhint %}

{% hint style="warning" %}
**2022년 NHN Cloud&#x20;**<mark style="color:red;">**행사/프로모션**</mark>**&#x20;정보 공유** : <https://doc.skill.or.kr/2022-NHN-Cloud-Event-Promotion>
{% endhint %}

## 1. Apache SSL to Tomcat SSL 보안인증서로 변경하여 사용하기         &#x20;

{% code title="Apache SSL 보안인증서를 Tomcat SSL 보안인증서로 변경 하자   " %}

```
# ls
ChainBundle.crt         www.kr_key.pem         GLOBALSIGN_ROOT_CA.crt         www.kr_apache.crt

# openssl pkcs12 -export -in www.kr_apache.crt -inkey www.kr_key.pem -out www.kr.keystore -name tomcat
Enter Export Password: [비밀번호입력]
Verifying - Enter Export Password: [비밀번호입력]

# ls
ChainBundle.crt         www.kr_key.pem         GLOBALSIGN_ROOT_CA.crt         www.kr_apache.crt         www.kr.keystore

```

{% endcode %}

{% hint style="info" %}
• SSL 인증서 파일 : 도메인 파일명 (예시: [www.gabia.com.crt](http://www.gabia.com.crt))

• 중개 인증서 : ALPHASSL\_CA\_\_SHA256\_\_G2.crt

• 루트 인증서 : GLOBALSIGN\_ROOT\_CA.crt

• 발급된 인증서 종류에 따라 루트, 체인 인증서 파일명은 다를 수 있습니다.
{% endhint %}

## 2. 생성된 test.keystore 를 이용하여 Tomcat 설정 하기

{% code title="server.xml 파일     " %}

```
    <Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol"
               maxThreads="150" SSLEnabled="true"
               keystoreFile="/home/centos/ssl/www.kr.keystore"
               keystorePass="[비밀번호]"
               sslProtocol="TLS" />
               
    <Connector port="8009" protocol="AJP/1.3" redirectPort="443" />
```

{% endcode %}

## 3. Tomcat server.xml 에서 HTTPS 로 자동 Redirect 설정      &#x20;

{% code title="server.xml 에서 HTTPS 로 자동 Redirect 설정 하기" %}

```
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />


<Connector port="80" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="443" />


<!-- JavaKeyStore 의 경우 -->
<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol"
               maxThreads="150" SSLEnabled="true"
               keystoreFile="/home/centos/ssl/www.kr.keystore"
               keystorePass="[비밀번호]"
               sslProtocol="TLS" />


<Connector port="8009" protocol="AJP/1.3" redirectPort="443" />
```

{% endcode %}

## 4. Tomcat web.xml 에 설정     &#x20;

{% code title="web.xml 의 마지막 부분에 입력. 모든 url 의 패턴을 https 로 Redirect 하기    " %}

```
<web-app>

<!-- 마지막 부분에 아래의 값을 입력-->
<security-constraint>
    <web-resource-collection>
        <web-resource-name>SSL Forward</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>

</web-app>
```

{% endcode %}

{% code title="web.xml 의 마지막 부분에 입력. 특정 url 의 패턴을 http or https 로 Redirect 하기  " %}

```
<security-constraint>
    <web-resource-collection>
        <web-resource-name>HTTPS or HTTP</web-resource-name>
        <url-pattern>/images/*</url-pattern>
        <url-pattern>/css/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
</security-constraint>

```

{% endcode %}

{% hint style="info" %}
**2022년 NHN Cloud&#x20;**<mark style="color:red;">**무료**</mark>**&#x20;교육일정** : <https://doc.skill.or.kr/2022-NHN-Cloud-Education>
{% endhint %}

{% hint style="warning" %}
**2022년 NHN Cloud&#x20;**<mark style="color:red;">**행사/프로모션**</mark>**&#x20;정보 공유** : <https://doc.skill.or.kr/2022-NHN-Cloud-Event-Promotion>
{% endhint %}

{% embed url="<https://paypal.me/shop2002>" %}
donation
{% endembed %}
