내가 읽으려고, 내맘대로 번역한 글.


//-----------------------------------------------------------------------------
// 번역자 : 이석우
// 번역일 : 2016.02.01
// 제목 : APACHE web server and SSL authentication
// 원문 : http://linuxconfig.org/apache-web-server-ssl-authentication
//-----------------------------------------------------------------------------
This article describes configuration techniques of module mod_ssl, which extends a functionality of Apache HTTPD to support SSL protocol. The article will deal with authentication of server (One-way SSL authentication), as well as it will also include authentication of clients by using certificates (Two-way SSL authentication).
이 글은 mod_ssl 모듈의 기술 설정에 대해서 기술한다.
mod_ssl은 SSL 프로토콜을 지원하기 위해 아파치 HTTPD를 확장한 기능이다.
이 글은 서버의 인증(one-way SSL 인증)을 다루고, 게다가 인증서를 사용하는 클라이언트의 인증(two-way SSL 인증)도 포함할거다.


1. Introduction

If you have decided to enable a SSL ( Secure Sockets Layer ) protocol on your web server it may be because you would like to extend its functionality to achieve an integrity and confidentiality for a data transferred on unsecured networks. However, this protocol with the combination of PKI ( Public Key Infrastructure ) principles can also along the side of integrity and confidentiality provide authentication between both sides involved in the client-server communication.
너가 웹서버에 SSL(Secure Sockets Layer) 프로토콜을 활성화하기로 결정했다면,
아마도 너는 안전하지 않은 네트워크에서 전송되는 데이타의 무결성과 기밀성을 얻기 위해서 기능을 확장하고 싶을것이다.
그러나, PKI의 조합이 프로토콜 (공개 키 인프라) 원칙도 무결성과 기밀성의 측면을 따라 클라이언트-서버 통신에 관련된 양측 사이의 인증을 제공 할 수 있다


One-way SSL authentication allows a SSL client to confirm an identity of SSL server. However, SSL server cannot confirm an identity of SSL client. This kind of SSL authentication is used by HTTPS protocol and many public servers around the world this way provides services such as webmail or Internet banking. The SSL client authentication is done on a “application layer” of OSI model by the client entering an authentication credentials such as username and password or by using a grid card.
One-way SSL authentication은 SSL클라이언트가 SSL서버의 신원을 확인할수 있게 한다.
SSL서버는 SSL클라이언트의 신원을 확인할수는 없다.
HTTPS프로토콜과 세계의 많은 공개서버에서 사용되는 이런 종류의 SSL인증은 웹메일, 인터넷뱅킹같은 서비스를 제공한다.
SSL클라이언트 인증은 OSI모델의 application layer 에서 이루어진다.
유저명과 비밀번호 또는 grid card 같은 인증자격을 입력하는 클라이언트에 의해.


Two-way SSL authentication also known as mutual SSL authentication allows SSL client to confirm an identity of SSL server and SSL server can also confirm an identity of the SSL client. This type of authentication is called client authentication because SSL client shows its identity to SSL server with a use of the client certificate. Client authentication with a certificate can add yet another layer of security or even completely replace authentication method such us user name and password.
Two-way SSL authentication은 mutual SSL 인증이라고도 알려졌고,
SSL서버는 SSL클라이언트의 신원을 확인할수 있고,
SSL클라이언트는 SSL서버의 신원을 확인할수 있다.
이런식의 인증은 클라이언트인증이라고 불리는데, SSL클라이언트가 클라이언트인증서를 사용해서 자신의 신원을 SSL서버에게 보여주기 때문이다.
인증서를 사용하는 클라이언트인증은 다른 보안레이어를 추가할수 있고, 유저명과 패스워드같은 인증방식을 완전히 바꿀수도 있다


In this document, we will discuss configuration of both types of SSL authentication one-way SSL authentication and two-way SSL authentication.
이 문서에서는 2가지 타입모두 논의할것이다.


2. Issuing OpenSSL certificates
2. OpenSSL 인증서 발행하기

...



3. One-way SSL authentication

Once the server's private key and certificate are ready, you can begin with SSL configuration of Apache web server. In many cases, this process is comprised of 2 steps – enabling mod_ssl and creating virtual host for port 443/TCP.
Enabling mod_ssl is very easy, all you need to do is to open httpd.conf file and remove comment mark from line:
LoadModule ssl_module modules/mod_ssl.so
Just because the server will serve the HTTPS requests on port 443 in is important to enable port 433/TCP in the apaches's configuration file by adding a line:
Listen 443
Definition of a virtual host can be also defined in “httpd.conf” file and should look as the one below:<VirtualHost _default_:443>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
                Options FollowSymLinks
                AllowOverride None        
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all        

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all

        LogLevel warn
        ErrorLog /var/log/apache2/error.log
        CustomLog /var/log/apache2/ssl_access.log combined

        SSLEngine on
        SSLCertificateFile    /etc/apache2/ssl/server.cer
        SSLCertificateKeyFile /etc/apache2/ssl/server.key

        BrowserMatch ".*MSIE.*"
                nokeepalive ssl-unclean-shutdown
                downgrade-1.0 force-response-1.0
</VirtualHost>
일단 서버의 개인키와 인증서가 준비되면, 아파치웹서버의 SSL 설정을 시작할수 있다.
많은경우 2개의 절차로 구성된다. mod_ssl 활성화와 TCP 443포를 사용하는 virtual host 만들기이다.
mod_ssl 활성화는 매우 쉽다. httpd.conf 파일을 열고 다음처럼 주석을 풀기만 하면 된다.
443번 포트에서 HTTPS 요청을 제공하는것이 중요하니까, 아파치 설정파일에서 다음 내용을 추가한다.
httpd.conf 파일에서 virtual host는 아래처럼 정의할수 있다.


In the example above directive “SSLEngine on” enables SSL support virtual host. Directive “SSLCertificateFile” defines a full path of the server's certificate and finally directive “SSLCertificateKeyFile” defines a full path to server's private key. If the private key is secured by password this password will be only needed when starting apache web server.
위의 예제에서 "SSLEngine on" 지시자는 SSL이 virutal host를 지원하도록 한다.
"SSLCertificateFile" 지시자는 서버인증서 전체경로를 정의한다.
마지막으로 "SSLCertificateKeyFile" 지시자는 서버개인키의 전체경로를 정의한다.
만약 개인키에 패스워드 걸려있다면 아파치웹서버를 시작할때 패스워드를 입력해야 한다.


Any changes to https.conf file such as the changes above require a web server restart. If you encounter some problems during the restart it is likely that this is due to configuration errors in your https.conf file. The actual error should appear in deamon's error log.
https.conf 파일이 변경되었으면 웹서버를 재기동해야 한다. 재기동시 문제가 생기면 https.conf 파일의 설정 오류 때문일것이다.
실제 에러는 데몬의 에러로그에 보여질거다.


Testing of a functionality of our new configuration can be done by using a web browser. The fist attempt to for connection most certainly displays an error message, that the attempt to verify server's certificate failed because, the issuer of the certificate is unknown.
우리의 새로운 설정을 테스트하는것은 웹브라우져를 통해서 가능하다. 연결하면 아마도 서버인증실패 에러메세지가 나타날것이다.
왜냐면, 인증서의 발행자를 알수 없기 때문이다.


Importing CA's certificate into the web browser's using its Certificate manager will solve this problem. To add a certificate into a Mozilla Firefox browser navigate to “Preferences > Advanced > Encryption > View certificates > Authorities” and during the import tick the box which says: “This certificate can identify web sites”.
Next attempt to connect the web server should be successful.
웹브라우져의 인증서관리자로 CA의 인증서를 가져와야 이 문제를 해결할수 있다.
모질라 브라우져에서 인증서를 추가하려면, Preferences > Advanced > Encryption > View Certificateds > Authorities 를 보면된다.
이제 다시 연결하면 성공할거다.


If you want to avoid the need of importing a CA's certificate into the web browser, you can buy server certificate from some commercial authority, which certificates are distributed by the web browser.
CA의 인증서를 웹브라우져로 가져오는걸 피하려면, 서버인증서를 돈주고 사야한다.



4. Two-way SSL authentication

If you have decided that you will require certificate authentication from every client, all you need to do is to add following lines into a virtual host configuration file:
SSLVerifyClient require
SSLVerifyDepth 10
SSLCACertificateFile /etc/apache2/ssl/ca.cer
만약 너가 모든 클라이언트의 인증서를 인증하기로 결정했으면, virtual host 설정파일에 다음의 내용을 넣으면 된다.


“SSLVerifyClient require” directive ensures that clients which do not provide a valid certificate from some of the trusted Certificate authorities would not be able to communicate with SSL server. Some CA rely on another CA, which may rely yet on another and so on. Directive “SSLVerifyDepth 10” specifies how far down in the chain of CA reliance, the server will accept CA signed certificate as valid. If, for instance, SSLVerifyDepth directive will hold value 1 then the client's certificate must be signed directly by your trusted CA. In this article, the client's certificate is signed directly by CA and therefore the only sensible value for SSLVerifyDepth directive is 1. Last directive “SSLCACertificateFile” specifies a full path to a Certificate Authority certificate by which a client's certificate was signed.
Do not forget to restart your apache web server after any change made to its configuration files:
# apachectl graceful
"SSLVerifyClient require" 지시자는 공인된 인증기관에서 발급된 유효한 인증서를 제출하지 않는 클라이언트는 SSL 서버와 통신할수 없도록 보장한다.
어떤 인증기관은 다른 인증기관에 연결되어 있고, 그 인증기관은 또다른 인증기관에 연결되어 있을수 있다.
"SSLVerifyDepth 10" 는 얼마다 깊게 CA가 의존적인지 기술하고, 서버가 공인인증 사인된 인증서를 유효하다고 받아들일지를 기술한다.
예를 들어 SSLVerifyDepth 지시자를 1 로 적으면, 클라이언트 인증서는 반드시 공인인증기관으로 부터 직접 사인된 인증서를 가자고 있어야 한다.
이글에서 클라이언트 인증서는 CA로 부터 직접 사인받은 인증서이고, 따라서 SSLVerifyDepth fmf 1로 적어도 된다.
마지막 지시자 "SSLCACertificateFile"는 클라이언트 인증서를 사인할 인증기관 인증서의 전체경로를 기술한다
설정파일을 변경한후에는 아파치웹서버를 재시작하는걸 잊지마라.


If you try to connect to the SSL server without a client certificate an error message will pop up:
클라이언트 인증서 없이 SSL 서버에 연결하려고 하면 에러창이 나올것이다.


All what needs to be done is to import previously created a client certificate in PKCS#12 form into to firefox's certificate manager under “Your Certificates” section. This task can be done by navigating to menu then “Preferences > Advanced > Encryption > View certificates > Your certificates”. During the import, you will be asked to enter a password which had been set during the creation of the certificate. Depending on the browser version you use, you may also need to set main password for software token, which is used by the browser to safely store certificates.
아까 만들어둔 클라이언트 인증서(PKCS#12 형식)를
파이어폭스의 인증서관리자 아래에서 "Your Certificates" 섹션에 넣어야. 이 에러를 없앨수 있다.
Preferences > Advanced > Encryption > View certificates > Your certificates 에서 할수 있다.
이걸 할때, 클라이언트 인증서를 만들때 생성한 패스워드를 입력해야 할것이다.
너가 사용하는 웹브라우져 버젼에 따라서, 브라우져가 인증서를 안전하게 관리할 목적의 메인 비밀번호를 넣어야 할수도 있다.


If you make another attempt to connect to the SSL server, browser will automatically pop-up an appropriate certificate for SSL server authentication.
After the selection of a valid certificate, the connection to the SSL server will be granted.
너가 다시 SSL 서버에 연결할때, 브라우져가 자동으로 SSL 서버 인증에 사용될 적절한 인증서를 보여줄것이다.
유효한 인증서를 선택한후에, SSL서버와의 연결이 성공할거다.



5. Another advantages of SSL authentication
Values from a client certificate can be used by web application for precise identification of the user. It is easy as to use a directive “SSLOptions +StdEnvVars” and mode_ssl will provide information taken from a client certificate as well as a certificate itself to the given web application.
웹어플리케이션에서 클라이언트 인증서의 값을 이용해서 사용자의 정확한 신원을 알수 있다.
SSLOptions +StdEnvVars 지시자를 사용하는것은 쉽고, mod_ssl 은 클라인언트 인증서로부터 정보를 가져와서 웹서버에 제공한다.


This operation will take a lot of server's run-time, and therefore, it is recommended to use this functionality on for files with certain extension or for files within certain directory as it is shown in the following example:<FilesMatch ".(cgi|shtml|phtml|php)$">
 SSLOptions +StdEnvVars
</FilesMatch>

<Directory /usr/lib/cgi-bin>
 SSLOptions +StdEnvVars
</Directory>
이 기능은 서버의 실시간 자원을 많이 소모한다. 따라서 특정한 상황에서만 이 기능을 사용한도록 권장된다.
(특정 파일확장자만 또는 특정 디렉토리에서만) 다음의 예처럼:


List of the available variables can be found in a module mod_ssl documentation. Accessing variables provided my mod_ssl is language specific. However, for the sake of completeness, here is a sample of CGI script written in perl which will display a “Common Name” of the client:
#!/usr/bin/perl
use strict;
print "Content-type: text/htmln";
print "n";
print $ENV{"SSL_CLIENT_S_DN_CN"}
사용가능한 변수들의 목록은 mod_ssl 문서에서 찾을수 있다. mod_ssl 이 제공하는 변수에 접근하는것은 특정언어다 (???)
여기 "Common Name" 을 표시하는 CGI 스크립트 예제가 있다.


Mod_ssl also supports a use of above mentioned variables directly from the server's configuration. This way you can restrict an access to some resources for employees of a certain company:
<Location /private/>
 SSLRequire %{SSL_CLIENT_S_DN_O} eq “Jariq.sk Enterprises”
 </Location>
These variables can be also used in conjunction with configuration directive “CustomLog” to enable logging a client's access details . More information can be found in the official mod_ssl documentation.



6. Conclusion

If you have not heard about Two-way SSL authentication yet, it is likely that after reading this article you asked yourself why is this type of SSL authentication not used often in the production environment. The answer is simple – cryptic operations used during SSL connections are difficult to process in regard to the web server resources. It is possible to boost web server performance by so called SSL accelerators ( cards containing a processor optimized for cryptic operations). However, in many cases SSL accelerators are more expensive than the server itself and therefore, Two-way SSL authentication is not attractive to use in the web server environment.
너가 아직 Two-way SSL 인증에 대해 들어보지 못했다면, 이 글을 읽고 나서, 왜 이러한 SSL 인증방식이 production 환경에서 자주 사용되지 않는지 스스로에게 물어보는게 좋을거다.
그 답은 간단하다. SSL 연결에 사용되는 암호화동작은 어렵고 웹서버 자원을 많이 쓴다.
SSL 가속기라는걸로 서버성능을 향샹시키는게 가능하지만, SSL 가속기는 대부분 서버자체보다 비싸다.
Two-way SSL 인증은 웹버서 환경에서 사용하기 매력적이지 않다.


7. Linux Apache2 specific notes:

7. 리눅스 아파치2

openning a port 443 is not required, if a configuration file /etc/apache2/ports.conf has defined an IfModule mod_ssl.c directive:

<IfModule mod_ssl.c>
 Listen 443
</IfModule>
ports.conf 파일에 아래의 내용이 있다면, 443 포트를 여는것은 필요하지 않다.


Enabling ssl module can be done by:

a2enmod ssl

If directive IfModule mod_ssl.c in /etc/apache2/ports.conf is defined command a2enmod ssl will also automatically enable listenning on port 443.

아래의 명령어를 실행시키기만 하면 ssl이 활성화 된다.
ports.conf 파일에 IfModule mod_ssl.c 지시자가 정의되어 있으면 a2enmod ssl 명령어는
자동으로 443포트를 리스닝하도록 활성화 한다.


Definition of virtual host file needs a slight change:

BrowserMatch “.*MSIE.*” \

nokeepalive ssl-unclean-shutdown \

downgrade-1.0 force-response-1.0

virtual host 에 약간의 변화가 있다.

반응형

'잡다한 자료' 카테고리의 다른 글

[번역] AWS_HIPAA_Compliance_Whitepaper  (0) 2016.03.14
GA. measurement protocol  (0) 2016.03.09
Apache. Ubuntu. SSL 설정  (0) 2016.01.06
aws. instance. clone. 복제  (2) 2016.01.05
mysql. federated 엔진  (0) 2015.11.25
Posted by 돌비
,