공통 OpenSSL의 설치 및 운영

황제낙엽 2007.09.27 21:56 조회 수 : 200 추천:107

sitelink1 http://user.chol.com/~laday/solaris/openssl.html 
sitelink2  
sitelink3  
sitelink4  
extra_vars5  
extra_vars6  

 

윈디하나의 솔라나라: OpenSSL

OpenSSL

설치할 OpenSSL 버전

  • OpenSSL 0.9.8a

OpenSSL을 사용할 어플리케이션 버전

  • Apache 2.0.50

들어가기 전에

  • OpenSSL은 보안 향상을 위해 사용된다. 그러나 OpenSSL에는 아직 버그가 존재하기 때문에, 수시로 OpenSSL의 버전을 확인해 업데이트 해주어야 한다.
  • SSL은 주로 패킷 스나이핑으로 인한 피해를 줄여줄 뿐이다. 그 이상은 안된다. 만능이 아니다! SSL 설치하고 '보안은 끝'이라고 생각하는 것은 오산일 뿐이다. [SSL을 설치했는데 왜 해킹을 당했나요?]라는 질문은 참 바보같은 질문이다. 해킹에는 수십~수백가지 방법이 있으며, SSL은 그중 하나인 패킷 스나이핑을 무력화할 뿐이다. (패킷스나이핑이 되지 않도록 하는게 아니라, 스나이핑 해봤자 내용이 암호화되어있어 무슨 내용인지 알 수 없도록 만드는 것이다)
  • SSL의 단점? 단 한가지있다. 느리다는 것이다. 느려도 너무 느리다. 패킷의 인코딩/디코딩에 많은 CPU자원을 소모한다. 필자는 이런 서버에는 과감히 다음과 같이 말한다. 'SSL 쓰지말아' 패킷 암호화를 하지 않아도 보안을 향상시킬 수 있는 다른 방법도 많다.
  • 최종 갱신일: 2007-04-19
  • 이 문서는 http://www.solanara.net/ 에서 최신버전을 구할 수 있다.

1. OpenSSL 설치

# 패키지 설치root@wl ~ # wget ftp://ftp.sunfreeware.com/pub/freeware/intel/9/openssl-0.9.8e-sol9-x86-local.gzroot@wl ~ # gunzip openssl-0.9.8e-sol9-intel-local.gzroot@wl ~ # pkgadd -d openssl-0.9.8e-sol9-intel-local# OpenSSL 소스 설치: http://www.openssl.orgroot@wl ~ # wget http://www.openssl.org/source/openssl-0.9.8e.tar.gzroot@wl ~ # gtar xvfz openssl-0.9.8e.tar.gzroot@wl ~ # cd openssl-0.9.8eroot@wl ~/openssl-0.9.8e # ./configroot@wl ~/openssl-0.9.8e # makeroot@wl ~/openssl-0.9.8e # make testroot@wl ~/openssl-0.9.8e # make install# 환경 설정root@wl ~ # vi /etc/profile# for OpenSSL located at /usr/local/sslif [ -d /usr/local/ssl ]then  PATH=$PATH:/usr/local/ssl/bin  LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/ssl/libfi

2. OpenSSL 인증서 만들기

root@wl ~ # cd /usr/local/ssl/certsroot@wl /usr/local/ssl/certs # openssl req -new -nodes -out req.pem -keyout req.keyGenerating a 1024 bit RSA private key.......++++++.......++++++writing new private key to '/usr/local/ssl/certs/root.cert'-----You are about to be asked to enter information that will be incorporatedinto your certificate request.What you are about to enter is what is called a Distinguished Name or a DN.There are quite a few fields but you can leave some blankFor some fields there will be a default value,If you enter '.', the field will be left blank.-----Country Name (2 letter code) [AU]:KRState or Province Name (full name) [Some-State]:GyungGiDoLocality Name (eg, city) []:SuwonOrganization Name (eg, company) [Internet Widgits Pty Ltd]:SolanaraOrganizational Unit Name (eg, section) []:SolanaraTeamCommon Name (eg, YOUR name) []:wl.solanara.net 1)Email Address []:admin@solanara.netPlease enter the following 'extra' attributesto be sent with your certificate requestA challenge password []:An optional company name []:root@wl /usr/local/ssl/certs # ls -alF 2)

1) Apache설정파일인 httpd.conf의 ServerName에 들어갈 값을 적어준다. 아파치는 이부분을 검사한다. 도메인이 있다면 www.company.com과 같이 전체를 다 써준다. 없다면 192.186.0.1과 같이 IP를 써도 된다. 다른 내용을 쓰면 인증을 다시 받아야 하는 불상사가 생길 수 있다. 유료 루트 인증기관에 보내기 전에 전화를 걸어 반드시 확인하도록 한다.
2) 총 2개의 파일이 생성되었다. req.key는 공개키이고, req.pem (certificate signing request)을 CA(Certification Authority=인증기관, 예: 베리사인, 타우트)에게 보내 인증 받아야 한다.

3. Root CA가 되기

CA에서 인증 받으려면 비용이 들기 때문에 테스트용으로는 자신이 CA가 될 필요가 있다. 그런데 CA가 되려면 Root CA(최상위 인증 기관)의 인증이 필요하다. 그리고 그 인증을 받기 위해서는 비용이 든다. 따라서 여기서는 Root CA가 되는 방법을 소개한다. Root CA도 CA중 하나이므로 CA가 하는 일을 모두 할 수 있다.

root@wl /usr/local/ssl/certs # openssl genrsa -des3 -out ca.key 1024 1)Generating RSA private key, 1024 bit long modulus............................++++++............++++++e is 65537 (0x10001)Enter pass phrase for ca.key:*****Verifying - Enter pass phrase for ca.key: *****root@wl /usr/local/ssl/certs # openssl req -new -x509 -days 365 -key ca.key -out ca.crt 2)Enter pass phrase for ca.key:You are about to be asked to enter information that will be incorporatedinto your certificate request.What you are about to enter is what is called a Distinguished Name or a DN.There are quite a few fields but you can leave some blankFor some fields there will be a default value,If you enter '.', the field will be left blank.-----Country Name (2 letter code) [AU]:KRState or Province Name (full name) [Some-State]:GyungGiDoLocality Name (eg, city) []:SuwonOrganization Name (eg, company) [Internet Widgits Pty Ltd]:SolanaraOrganizational Unit Name (eg, section) []:SolanaraTeamCommon Name (eg, YOUR name) []:WindyHanaEmail Address []:admin@solanara.netroot@wl /usr/local/ssl/certs # openssl x509 -req -CA ca.crt -CAkey ca.key -days 365 -in req.pem -out signed-req.pem -CAcreateserial 3)Signature oksubject=/C=KR/ST=GyungGiDo/L=Suwon/O=Solanara/OU=SolanaraTeam/CN=wl.solanara.net/emailAddress=admin@solanara.netGetting CA Private KeyEnter pass phrase for ca.key:*****root@wl /usr/local/ssl/certs # chmod 600 *root@wl /usr/local/ssl/certs # ls -alF 4)총 18drwxr-xr-x   2 root     bin          512 10월 26일  13:44 ./drwxr-xr-x  10 root     bin          512 10월 26일  13:40 ../-rw-------   1 root     other       1074 10월 26일  13:44 ca.crt-rw-------   1 root     other        963 10월 26일  13:43 ca.key-rw-------   1 root     other         17 10월 26일  13:44 ca.srl-rw-------   1 root     other        887 10월 26일  13:43 req.key-rw-------   1 root     other        676 10월 26일  13:43 req.pem-rw-------   1 root     other        855 10월 26일  13:44 signed-req.pemroot@wl /usr/local/ssl/certs # 

1) Root CA의 1024bit private key 파일을 만든다. 결과 파일은 ca.key 이다.
2) 인증서를 만든다. 결과파일은 ca.crt파일이다. ca.crt를 Internet Explorer에 등록해주면 '올바르지 않은 CA'라는 에러메시지를 없앨 수 있다.
3) 이제 Root CA가 되는 일은 끝났다. 클라이언트가 요청한 req.pem을 싸인해주자. 결과파일은 signed-req.pem이다. 베리싸인과 같은 인증 기관은 이 명령 한줄만 실행 해주면 된다. (그러면서 도대체 얼마를 받는거야... ㅡ,.ㅡ)
4) ca.key와 req.key는 소중하게 보관해야 한다. 절대 외부에 유출되서는 안된다.
아파치와 같은 여러 유닉스 데몬에서 SSL을 사용할 때 사용되는 파일은 req.key와 signed-req.pem의 내용이며, 몇몇 데몬은 ca.crt의 내용까지 요구하는 경우도 있다. (형태가 파일인 경우가 대부분이지만 DB에 저장된 문자열일 수도 있다. 실제로 req.key 와 signed-req.pem 은 vi 에디터등으로 열어 내용을 볼 수 있는 텍스트 파일이다) ca.key파일은 디스켓에 담아 별도로 보관한다. (이것이 유출되지 않아야 SSL의 보안이 안전해진다. CA는 이 키 파일의 보안에 많은 비용을 들인다)

3. 어플리케이션 설치

※ Apache 프로그램 설치

root@wl ~/httpd-2.0.50 # ./configure --prefix=/usr/local/apache2 --enable-so --with-mpm=worker  --enable-ssl --with-ssl=/usr/local/sslroot@wl ~/httpd-2.0.50 # makeroot@wl ~/httpd-2.0.50 # make installroot@wl ~/httpd-2.0.50 # mkdir /usr/local/apache2/conf/ssl.keyroot@wl ~/httpd-2.0.50 # cd /usr/local/apache2/conf/ssl.keyroot@wl /usr/local/apache2/conf/ssl.key # ln -s /usr/local/ssl/certs/req.key server.key # Server Private Keyroot@wl /usr/local/apache2/conf/ssl.key # mkdir /usr/local/apache2/conf/ssl.crtroot@wl /usr/local/apache2/conf/ssl.key # cd /usr/local/apache2/conf/ssl.crtroot@wl /usr/local/apache2/conf/ssl.crt # ln -s /usr/local/ssl/certs/signed-req.pem server.crt # Server Certificateroot@wl /usr/local/apache2/conf/ssl.key # apachectl startssl # 아파치 시작. apachectl start 만하면 SSL이 시작되지 않는다.root@wl /usr/local/apache2/conf/ssl.key # apachectl stop # 아파치 종료

http://www.linuxquestions.org/questions/showthread.php?t=271170 PassPHASE없애기 cp server.key server.key.original openssl rsa -in server.key.original -out server.key chmod 400 server.key

번호 제목 sitelink1 글쓴이 날짜 조회 수
공지 [계속 추가중] SBOM 용어 정의   황제낙엽 2025.04.10 52
공지 [계속 추가중] Keycloak 용어 및 설정 옵션 정의   황제낙엽 2024.02.02 631
25 blowfish 알고리즘 file http://www.schneier.com/blowfish.html  황제낙엽 2008.01.22 239
24 OpenSSL을 이용한 보안 통신 API의 설계 및 구현 file   황제낙엽 2007.10.01 193
23 Windows환경에서의 OpenSSL설치 file   황제낙엽 2007.09.28 145
22 OpenSSL Command-Line HOWTO   황제낙엽 2007.09.27 437
21 Certificate Server의 설치 와 Client인증 http://wiki.kldp.org/wiki.php/LinuxdocSgml/OpenSSL-KLDP  황제낙엽 2007.09.27 310
» OpenSSL의 설치 및 운영 http://user.chol.com/~laday/solaris/openssl.html  황제낙엽 2007.09.27 200
19 OpenSSL 프로그래밍   황제낙엽 2007.09.27 1363
18 OpenSSL 을 통한 파일 암호화   황제낙엽 2007.09.27 361
17 OpenSSL 과 OpenSSH 소스 파일 (Language : C)   황제낙엽 2007.09.24 181
16 RSA 암호화 알고리즘을 구현한 C++ 예제 file http://labs.jong10.com/category/cryptology  황제낙엽 2007.09.17 1400
15 RSA암호화를 이용한 로그인 ID/패스워드 정보 관리 http://blog.dalsu.net/61  황제낙엽 2007.09.05 258
14 PHP와 OpenSSL http://www.ecoop.net/memo/2007-04-26-3.html  황제낙엽 2007.09.27 272
13 RSA 공개키 암호화 알고리즘 - PHP 구현[2] file   황제낙엽 2007.09.27 393
12 RSA 공개키 암호화 알고리즘 - PHP 구현[1] file   황제낙엽 2007.09.05 179
11 OpenSSL사용방법 메모, RSA암호의 최대 사이즈, JCA/JCE가이드   황제낙엽 2007.09.27 173
10 Java Cryptography Extension (JCE) 개요   황제낙엽 2007.09.27 345
9 Java에서 암호화하고 C++에서 복호화하는 방법   황제낙엽 2007.09.27 378
8 비밀키를 Keytool에서 취급할 수 있는 형식으로 변환방법 http://java-house.jp/ml/archive/j-h-b/051472.html  황제낙엽 2007.09.27 229
7 공개키 암호화의 수학적 알고리즘과 자바 구현   황제낙엽 2007.09.22 207
6 RSA 암호화 알고리즘을 구현한 자바예제 (산술계산)   황제낙엽 2007.09.17 326