기본 콘텐츠로 건너뛰기

OpenSSL 이란 openssl update

SSL이란 Secure Socket Layer로 월드 와이드 웹 브라우저와 웹 서버 간에 데이터를 안전하게 주고 받기 위한 업계 표준 프로토콜을 의미한다.

: 오픈소스 라이브러리(OpenSSL)
공식 홈페이지: https://www.openssl.org/

OpenSSL 사용법
http://roiztoy.blogspot.kr/2013/11/openssl.html

SSL서비스 구축 및 OpenSSL

http://wiki.tunelinux.pe.kr/pages/viewpage.action?pageId=884976

명령어 : http://repien.tistory.com/36

1) openssl 버전 확인
openssl version

2) 키 생성
openssl genrsa -des3 -out 키이름.key 1024 : 3DES로 암호화. 비밀번호 설정 필요.

3) 암호화 하지 않고 키 생성
openssl genrsa -out 키이름.key 1024


3-1) 비밀키로 공개키 생성
openssl rsa -in 비밀키명.key -pubout -out 공개키명.key


4) 기존 비밀키에 패스워드 추가
openssl rsa -in out 키이름.key -des3 -out 새키이름.key

5) 기존 비밀키에 패스워드 제거
openssl rsa -in 키이름.key -out 새로운키이름.key

6) 키 내용 확인
openssl 키종류 -noout -text -in 키이름.key
ex) openssl rsa -noout -text -in 키이름.key


7) 자체 서명 인증서 생성
openssl req -new -key 키이름.key -x509 -out 인증서이름.crt
openssl req -new -x509 -nodes -sha1 -days 365 -key server.key -out server.crt


Enter pass phrase for test.key:
You are about to be asked to enter information that will be incorporated
into 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 blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]: 국가 코드(2자리)
State or Province Name (full name) [Some-State]: 주 / 도
Locality Name (eg, city) []: 시
Organization Name (eg, company) [Internet Widgits Pty Ltd]: 회사명 등
Organizational Unit Name (eg, section) []: 부서 등
Common Name (e.g. server FQDN or YOUR name) []: 이름이나 서버 주소
Email Address []: 이메일 주소



8) 인증서 확인
openssl x509 -noout -text -in 인증서파일.crt
openssl x509 -in ca.der -inform DER -text (DER 포맷인 경우)

9) DSA key 생성

(1) parameters 생성
openssl dsaparam -out 파라미터.pem 2048

(2) key 생성
openssl gendsa -des3 -out 키이름.key 파라미터.pem

10) CSR생성 (인증서 서명 요청을 위해 필요)
openssl req -new -key 키이름.key -out csr이름.csr

10-1) CSR 확인
openssl req -noout -text -in csr이름.csr



11) pkcs12 변환
openssl pkcs12 -export -in 파일명 -inkey 키이름.key -out pfx명.pfx


12) 인증서 인코딩 포멧 변경
- openssl 이 생성하는 인증서의 인코딩은 발급 시 옵션을 주지 않으면 디폴트가 PEM (base64 encoding)이다.
- Java 등에서 사용하기 위한 DER 포맷(바이너리)으로 변경은 다음과 같이 수행한다.
openssl x509 -in ca.crt -out ca.der -outform DER

업데이트:
참조 사이트http://lifepolio.tistory.com/38

### 주요 디렉토리 리스트

/usr/bin/  ( 기존 openssl 바이너리 파일 위치 )

/root/      ( 기존 openssl 바이너리 백업할 위치 )

/usr/local/ssl  ( openssl 소스 빌드 완성되면 생성되는 디렉토리 )

/usr/loacl/src  ( wget으로 openssl 다운로드 할 위치 )


/usr/local/ssl/bin ( 새롭게 반영할 openssl 바이너리 파일 위치 )

### 설치 전 확인 사항


1. openssl 버전 확인

- 1.0.1s 버전이 아니면 모두 업데이트 대상
- openssl version

2. gcc 프로그램 설치 여부

- 현재 업데이트 할 버전은 소스설치로 진행하기 때문에 컴파일시 gcc 필요
- rpm -qa | grep gcc
- gcc 프로그램이 없다면 yum install gcc 입력


### openssl wget 명령어를 이용한 소스 다운로드

1. 다운로드 받을 디렉토리 이동

- cd /usr/local/src

2. openssl 다운로드

- wget ftp://ftp.openssl.org/source/openssl-1.0.1s.tar.gz

3. openssl 압축 해제

- tar xzvf openssl-1.0.1s.tar.gz


### openssl 빌드 진행

1. openssl 소스 설치 디렉토리 이동

- cd openssl-1.0.1s

2. ./config 실행

- ./config 입력 ( config 아닙니다 )

3. make 실행

- make 입력 ( ./make 아닙니다. )

- 약 1~5분 실행


4. make install 실행

- make install 입력 ( ./make install 아닙니다. )

- 약 1분 진행


### openssl 적용

1. 빌드 진행후 /usr/local/ssl 생성 확인

2. openssl 버전 확인

- openssl version 입력
- 여전히 과거 버전이 적용되어 있다.

3. openssl 바이너리 파일 위치 확인

- which openssl 입력 ( 대부분 /usr/bin/openssl 위치에 있음 )

4. 기존 openssl 바이너리 파일 백업

- mv /usr/bin/openssl /root/

5. 빌드된 openssl 실행파일 적용

-  링크걸기 or 복사하기

-  ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
-  cp /usr/local/ssl/bin/openssl /usr/bin/openssl

-  둘중 한가지 선택 후 실행
-  본 문서에서는 링크로 진행


6. openssl 버전 확인

- openssl version ( 1.0.1s 버전인지 확인 요망 )





### 추가적인 정보

1. 최신 버전의 openssl 사이트 주소

- ftp://ftp.openssl.org/source/   ( 최신 버전 하나씩 업로드 되어 있음 )

댓글

이 블로그의 인기 게시물

[Java] Http File Download 이어받기

Http 서버로부터 다운로드 받는 파일을 이어받기 위해서는 Http Header에 아래 두가지 정보를 추가해 주면 된다. URLConnection conn = url.openConnection(); conn.setRequestProperty("Accept-Ranges", "bytes"); conn.setRequestProperty("Range", "bytes=" + mOffset + "-"); 그러면 서버에서는 해당 Offset으로부터 File을 다운로드 시켜준다. 클라이언트가 요청헤더에 Range 필드를 포함 시켜서 보내면, 서버는 그 정보를 가지고 어디서 부터 파일을 보낼지 판단을 합니다. 하지만 클라이언트가(브라우저) Range 필드를 포함 시켜야 할지를 판단하는 기준은 최초 다운로드 요청시 서버의 응답헤더에 따라 다음 요청헤더에 Range 헤더를 생성할지 않할지 판단하게 됩니다. 그걸 당락짓는 응답 헤더 필드는 다음과 같습니다. Accept-Ranges , ETag, Last-Modified 반드시 위 필드를 응답 헤더에 같이 보내줘야 클라이언트는 다음 요청시 Range헤더를 포함시켜 보내게 됩니다. 참고로 말씀 드리면 위 필드를 포함 시켜서 보내더라도 value는 반드시 " " 로 묶어서 보내야 합니다. 안그러면 브라우저는 죽어도 Range 필드를 생성시키지 않습니다. HTTP 1.1 스펙은 따옴표를 강제적으로 해줘라 이런 내용 없습니다. 자바기준 40byte의 파일이라치면 클리이언트 요청을 두번으로 나누었다치면 이케 connection.setRequestProperty("Range", "bytes=0-20"); connection.setRequestProperty("Range", "bytes=20-40"); 단 co...

java 특정 디렉토리에 있는 파일 목록을 읽어내기, 정렬해서 가져오기

폴더 리스트 가져오기 String path="C:\"; File dirFile=new File(path); File []fileList=dirFile.listFiles(); for(File tempFile : fileList) {   if(tempFile.isFile()) {     String tempPath=tempFile.getParent();     String tempFileName=tempFile.getName();     System.out.println("Path="+tempPath);     System.out.println("FileName="+tempFileName);     /*** Do something withd tempPath and temp FileName ^^; ***/   } } 정렬해서 가져오기 import java.io.FileFilter; import java.io.IOException; import java.util.Arrays; import java.util.Date; import org.apache.commons.io.comparator.LastModifiedFileComparator; import org.apache.commons.io.filefilter.FileFileFilter; public class LastModifiedFileComparatorTest { public static void main(String[] args) throws IOException { File directory = new File("."); // get just files, not directories File[] files = directory.listFiles((FileFilter) FileFileFilter.FILE); System.out.println("Defaul...