Complete Virtual Mail Server/SSL Certificates/ko

도입부
오늘날 보안과 개인정보 처리는 점점 중요한 문제가 되기에, 서버 보안에 SSL을 활용하는건 쉬워 보입니다. Apache, Courier-imap, postfix 모두 SSL로 보안처리할 수 있습니다.

SSL 설치
SSL is a dependency and a compile time option to most packages. being the key ingredient, should be pulled in from the  USE flag. If it wasn't set before enable it and update all packages using it:

SNI
There are a few issues that arise when using multiple domains on a single IP. Apache has solved this issue using SNI that makes it possible to have several certificates on a single IP. Both the browser and the server need to support this however. IMAP (and POP3) nor SMTP really support this. The only real way to support multiple hosts on a single IP is have a certificate, that covers all domains. Not pretty but can work.

SSL 인증서 취득
There are currently 2 and a half ways to obtain an SSL certificate. Purchase a certificate from one of the reputable providers is an option. Using a self-signed certificate can also be done, though may have implications with warnings on users clients. The half option, which is the recommended option when not using a bought certificate is using a certificate from [//cacert.org cacert.org]. They are working hard on getting their certificate included into the main browsers and operating systems, but most of all, it is free and gratis.

자체 서명
Most applications pre-generate self signed certificates and tend to install then into. A new self-signed certificate can be easily created using OpenSSL:

This should have created three files:, , and it's accompanying CA Root certificate. It is probably advised to rename them to something more logical.

CACert.org 서명
CACert.org offers a simple script to assist with generating SSL certificates. The [//wiki.cacert.org/CSRGenerator csr] script should be downloaded and executed. In this example, the mail server will be called imap but will have aliases configured in DNS for mail, pop, pop3, pop3s, imaps and foo. More can be added of course as fit. Note that foo was added because that is the name of the system offering the imap service. It is not named foo because the postfix or web or any other server is named foo.

This has generated a certificate sign request, which can be used by any root CA to sign with, not only CACert.org. In the case of CACert.org however, under Server Certificates there is a link named New which opens an edit box for the above certificate request. The bit including  until, including   needs to be pasted into the edit field and then submitted via the submit button. The server will then verify the request and upon that generate the certificate. The certificate then needs to be copied and pasted, including the  and   markers again into a new file, named. A link to the certificate will also be e-mailed to the e-mail address bound to the ca-cert.org account.

This should leave 3 files,. This will also be the naming convention followed during the rest of this document.

Apache
Setting up Apache is already very well described elsewhere and yields a working SSL enabled webserver. Postfixadmin, if used externally, should ideally be secured such that it only works over https. Roundcube or webmail in general, can also be setup to be secured by SSL, but should or can be still open to plain HTTP.

Roundcube has one nice option for this however, to force all incoming requests over HTTPS. This means that when a users opens http://webmail.example.com, he will get immediately redirected to https://webmail.example.com. If using a proper SSL certificate this is strongly recommended. When using a self-signed certificate, or a CA-cert.org certificate that does not have the root installed to all users, this should remain off however.

Courier-imap
If anything, securing IMAP with SSL is extremely recommended. Using a secure connection for IMAP, means that if the password is sent in plain text, this is still done over the secured IMAP connection so no security issue comes up.

자체 서명 인증서 만들기
Courier-imap comes with two easy scripts to generate self-signed SSL certificates, mkpop3dcert and mkimapdcert. These scripts parse and  respectively. It may be an idea to first use self-signed certificates and then swap those out for signed certificates as it can make testing a little bit easier. If self-signed certificates are a must, edit the aforementioned files, otherwise the defaults will suffice.

CACert.org 서명 인증서 만들기
The mkimapdcert script creates a self-signed certificate and combines them into one file as Courier-imap does actually not use the three separate files as most applications do and needs them specially formatted.

파일은 개인키로 시작합니다.

그 다음 서명 인증서를 따릅니다:

마지막으로 Diffie-Hellman 매개변수를 추가했습니다:

결과는 다음과 같아야합니다:

SSL 설정
As noted above, the certificate entails both pop3 as imap hostnames and it is thus assumed pop3 and imap are running on the same IP/host. This is not required however, pop3 could be very well a different machine with the same (not advised) or its own certificate.

POP3
서버를 시작할 때 SSL에서 pop3를 동작하게 해야합니다:

IMAP
서버를 시작할 때 IMAP이 SSL에서 동작하도록 해야합니다:

SSL 시험
Testing becomes more difficult, as telnet can not be used anymore. The best option is to start up a mail-client such as thunderbird, configure a normal connection first to verify everything works, which should as telnet worked properly before and then enable the SSL option for the account and see if it is still working. The default imap-ssl port is 993. can be checked whether it is enabled only, via telnet, by checking for the STARTTLS Capability.

기대하던대로 SSL 보안 서비스가 동작한다면 기본 런레벨에 추가할 수 있습니다:

SSL로 SMTP 보안 처리
The certificates for use with postfix should be stored in or if using the same certificates as with courier-imap they should be stored in. If using CACert.org, then its root certificate needs to be used. Gentoo pre-installs the CACert.org root certificate and should be used.

Now STARTTLS can be used to use an authenticated connection over port 25. SSL/TLS support on port 465 (smtps) however should be enabled as well. Courier-imap did this automatically, postfix needs a change to :

SSL로 보안 처리한 데몬을 시작하려면 postfix를 다시 시작하십시오:

시험
Telnet can only be minimally used for testing. Actually it can only be used to verify supported options. STARTTLS should be listed as one of the supported options:

To test if all connections work as wanted, a recent version of Thunderbird works best. When adding a new account, Thunderbird will try to connect using STARTTLS on the default port. If that would fail, or if a manual connection is tried, it's possible to use SSL/TLS via the 993 and 465 ports and hit the re-test button. This should allow the account to be created using secure connections.

서버간 연결 보안
Postfix can try to use secure connections for sending mails to other SMTP servers. Although it may not be supported by all servers, it makes sense to activate it.

다음 postfix를 다시 시작하십시오:

To test if it works, a mail can be sent to an address, which uses a server that supports TLS. The log should then contain a line like this:

마무리
Once everything is working as expected, logging can be disabled again: