• MySQL매뉴얼
    • MySQL 5.6 매뉴얼
    • MySQL 5.1 매뉴얼
    • MySQL 5.0 매뉴얼
    • MySQL HA 매뉴얼
  • 기술문서
    • Xtrabackup 구성
    • 메모리 사용량 모니터링
  • 라이선스
  • 온라인문의
  • 회사소개
  • → 목 록 (MySQL5.6 한글메뉴얼) [close]
  • 1. MySQL 5.6 새로운 기능
  • 2. MySQL 설치 및 업그레이드
  • 3. MySQL Tutorial
  • 4. MySQL 프로그램
  • 5. MySQL 서버관리
  • 6. 보안
  • 1. 일반적인 보안 문제
    2. MySQL 권한 시스템
    3. MySQL 사용자 계정 관리
    1. 사용자 이름과 암호
    2. 사용자 계정 추가
    3. 사용자 계정 삭제
    4. 계정 자원 제한 설정
    5. 계정 암호 지정
    6. 암호 만료 및 샌드 박스 모드
    7. 플러그 인증
    8. MySQL에서 사용 가능한 인증 플러그인
    9. 프록시 사용자
    10. 보안 연결을 위해 SSL 사용
    1. 기본적인 SSL 개념
    2. SSL을 사용하는 MySQL의 구성
    3. SSL 연결 사용
    4. 명령 옵션
    5. MySQL에서의 SSL 인증서 및 키 설정
    11. SSH를 사용하여 Windows에서 MySQL에 대한 원격 연결
    12. MySQL Enterprise Audit 로그 플러그인
    13. SQL 기반의 MySQL 계정 활동 감사
  • 7. 백업 및 복구
  • 8. 최적화
  • 9. Language Structure(언어구조)
  • 10. Character Sets(Globalization)
  • 11. 데이터형(Data Types)
  • 12. 함수와 연산자
  • 13. SQL 문법
  • 14. InnoDB 스토리지 엔진
  • 15. 기타 스토리지 엔진
  • 16. 고가용성 및 확장성
  • 17. 리플리케이션
  • 18. MySQL Cluster
  • 19. 파티셔닝
  • 20. Stored Programs and Views
  • 21. INFORMATION_SCHEMA
  • 22. PERFORMANCE SCHEMA
  • 23. 컨넥터 및 API
  • 24. MySQL 확장
  • 25. MySQL Enterprise Edition
  • 26. MySQL Workbench
  • 27. 제약 및 제한
  • 28. MySQL 5.7 새로운 기능

6.3.10.5 MySQL에서의 SSL 인증서 및 키 설정

이 섹션에서는 MySQL 서버 및 클라이언트에서 사용되는 SSL 인증서와 키 파일을 설정하는 방법을 보여줍니다. 첫 번째 예제는 명령 행에서 사용하는 경우 등의 단순화 된 절차를 보여줍니다. 두 번째는 자세한 것을 포함하는 스크립트를 나타냅니다. 처음 두 예제는 Unix에서 사용하기위한 것이며, 두 예에서 OpenSSL의 일부인 openssl 명령이 사용됩니다. 세 번째 예에서는 Windows에서 SSL 파일을 설정하는 방법을 설명합니다.

중요

인증서 및 키 파일을 생성 할 때 어떤 방법을 사용하는지에 관계없이 서버 및 클라이언트의 인증서와 키에 사용되는 Common Name 값은 각각 CA 인증서에서 사용되는 Common Name 값과 달라야합니다. 그렇지 않으면 OpenSSL을 사용하여 컴파일 된 서버에서 인증서 및 키 파일이 작동하지 않습니다. 이 경우 일반적인 오류는 다음과 같습니다.

 ERROR 2026 (HY000) : SSL connection error :
 error : 00000001 : lib (0) : func (0) : reason (1)
예 1 : Unix 명령 행에서 SSL 파일을 만듭니다

다음 예제는 MySQL 서버와 클라이언트의 인증서와 키 파일을 작성하기위한 명령 세트를 나타냅니다. openssl 명령으로 여러 프롬프트에 응답해야합니다. 모든 프롬프트에서 Enter 키를 누르면 테스트 파일을 생성 할 수 있습니다. 프로덕션 환경에 대한 파일을 생성하려면 비어 있지 않은 답변을 제공하도록하십시오.

# Create clean environment shell> rm -rf newcerts shell> mkdir newcerts && cd newcerts # Create CA certificate shell> openssl genrsa 2048 > ca-key.pem shell> openssl req -new -x509 -nodes -days 3600 \ -key ca-key.pem -out ca-cert.pem # Create server certificate, remove passphrase, and sign it # server-cert.pem = public key, server-key.pem = private key shell> openssl req -newkey rsa:2048 -days 3600 \ -nodes -keyout server-key.pem -out server-req.pem shell> openssl rsa -in server-key.pem -out server-key.pem shell> openssl x509 -req -in server-req.pem -days 3600 \ -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 -out server-cert.pem # Create client certificate, remove passphrase, and sign it # client-cert.pem = public key, client-key.pem = private key shell> openssl req -newkey rsa:2048 -days 3600 \ -nodes -keyout client-key.pem -out client-req.pem shell> openssl rsa -in client-key.pem -out client-key.pem shell> openssl x509 -req -in client-req.pem -days 3600 \ -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 -out client-cert.pem

인증서가 생성되면이를 확인합니다.

 shell> openssl verify -CAfile ca-cert.pem server-cert.pem client-cert.pem
 server-cert.pem : OK
 client-cert.pem : OK

이 시점에서 다음과 같은 파일 세트를 사용할 수 있습니다.

  • ca-cert.pem : 이것은 서버 측과 클라이언트 측에서 --ssl-ca 에 대한 인수로 사용합니다. (CA 인증서를 사용하는 경우는 양쪽에서 동일하게 지정해야합니다.)

  • server-cert.pem , server-key.pem :이 서버 측에서 --ssl-cert 및 --ssl-key 에 대한 인수로 사용합니다.

  • client-cert.pem , client-key.pem : 이들은 클라이언트 측에서 --ssl-cert 및 --ssl-key 에 대한 인수로 사용합니다.

파일을 사용하여 SSL 연결을 테스트하는 방법은 섹션 6.3.10.3 "SSL 연결 사용" 을 참조하십시오.

예 2 : Unix에서 스크립트를 사용하여 SSL 파일을 만들

다음은 MySQL에 SSL 인증서와 키 파일을 설정하는 방법을 보여주는 예제 스크립트를 나타냅니다. 스크립트를 실행 한 후, 섹션 6.3.10.3 "SSL 연결 사용" 에 설명 된대로 파일을 사용하여 SSL 연결을 테스트합니다.

 DIR =`pwd` / openssl
 PRIV = $ DIR / private

 mkdir $ DIR $ PRIV $ DIR / newcerts
 cp /usr/share/ssl/openssl.cnf $ DIR
 replace ./demoCA $ DIR - $ DIR / openssl.cnf

 # Create necessary files : $ database, $ serial and $ new_certs_dir
 # directory (optional)

 touch $ DIR / index.txt
 echo "01"> $ DIR / serial

 #
 # Generation of Certificate Authority (CA)
 #

 openssl req -new -x509 -keyout $ PRIV / cakey.pem -out $ DIR / ca-cert.pem \
     -days 3600 -config $ DIR / openssl.cnf

 # Sample output :
 # Using configuration from /home/monty/openssl/openssl.cnf
 # Generating a 1024 bit RSA private key
 # ................ ++++++
 # ......... ++++++
 # writing new private key to '/home/monty/openssl/private/cakey.pem'
 # Enter PEM pass phrase :
 # Verifying password - Enter PEM pass phrase :
 # -----
 # 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] : FI
 # State or Province Name (full name) [Some-State] :.
 # Locality Name (eg, city) [] :
 # Organization Name (eg, company) Internet Widgits Pty Ltd : MySQL AB
 # Organizational Unit Name (eg, section) [] :
 # Common Name (eg, YOUR name) [] : MySQL admin
 # Email Address [] :

 #
 # Create server request and key
 #
 openssl req -new -keyout $ DIR / server-key.pem -out \
     $ DIR / server-req.pem -days 3600 -config $ DIR / openssl.cnf

 # Sample output :
 # Using configuration from /home/monty/openssl/openssl.cnf
 # Generating a 1024 bit RSA private key
 # .. ++++++
 # .......... ++++++
 # writing new private key to '/home/monty/openssl/server-key.pem'
 # Enter PEM pass phrase :
 # Verifying password - Enter PEM pass phrase :
 # -----
 # 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] : FI
 # State or Province Name (full name) [Some-State] :.
 # Locality Name (eg, city) [] :
 # Organization Name (eg, company) Internet Widgits Pty Ltd : MySQL AB
 # Organizational Unit Name (eg, section) [] :
 # Common Name (eg, YOUR name) [] : MySQL server
 # Email Address [] :
 #
 # Please enter the following 'extra'attributes
 # to be sent with your certificate request
 # A challenge password [] :
 # An optional company name [] :

 #
 # Remove the passphrase from the key
 #
 openssl rsa -in $ DIR / server-key.pem -out $ DIR / server-key.pem

 #
 # Sign server cert
 #
 openssl ca -cert $ DIR / ca-cert.pem -policy policy_anything \
     -out $ DIR / server-cert.pem -config $ DIR / openssl.cnf \
     -infiles $ DIR / server-req.pem

 # Sample output :
 # Using configuration from /home/monty/openssl/openssl.cnf
 # Enter PEM pass phrase :
 # Check that the request matches the signature
 # Signature ok
 # The Subjects Distinguished Name is as follows
 # countryName : PRINTABLE : 'FI'
 # organizationName : PRINTABLE : 'MySQL AB'
 # commonName : PRINTABLE : 'MySQL admin'
 # Certificate is to be certified until Sep 13 14:22:46 2003 GMT
 # (365 days)
 # Sign the certificate? [y / n] : y
 #
 #
 # 1 out of 1 certificate requests certified, commit? [y / n] y
 # Wr​​ite out database with 1 new entries
 # Data Base Updated

 #
 # Create client request and key
 #
 openssl req -new -keyout $ DIR / client-key.pem -out \
     $ DIR / client-req.pem -days 3600 -config $ DIR / openssl.cnf

 # Sample output :
 # Using configuration from /home/monty/openssl/openssl.cnf
 # Generating a 1024 bit RSA private key
 # ................................. ++++++
 # ............................................. + + + + ++
 # writing new private key to '/home/monty/openssl/client-key.pem'
 # Enter PEM pass phrase :
 # Verifying password - Enter PEM pass phrase :
 # -----
 # 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] : FI
 # State or Province Name (full name) [Some-State] :.
 # Locality Name (eg, city) [] :
 # Organization Name (eg, company) Internet Widgits Pty Ltd : MySQL AB
 # Organizational Unit Name (eg, section) [] :
 # Common Name (eg, YOUR name) [] : MySQL user
 # Email Address [] :
 #
 # Please enter the following 'extra'attributes
 # to be sent with your certificate request
 # A challenge password [] :
 # An optional company name [] :

 #
 # Remove the passphrase from the key
 #
 openssl rsa -in $ DIR / client-key.pem -out $ DIR / client-key.pem

 #
 # Sign client cert
 #

 openssl ca -cert $ DIR / ca-cert.pem -policy policy_anything \
     -out $ DIR / client-cert.pem -config $ DIR / openssl.cnf \
     -infiles $ DIR / client-req.pem

 # Sample output :
 # Using configuration from /home/monty/openssl/openssl.cnf
 # Enter PEM pass phrase :
 # Check that the request matches the signature
 # Signature ok
 # The Subjects Distinguished Name is as follows
 # countryName : PRINTABLE : 'FI'
 # organizationName : PRINTABLE : 'MySQL AB'
 # commonName : PRINTABLE : 'MySQL user'
 # Certificate is to be certified until Sep 13 16:45:17 2003 GMT
 # (365 days)
 # Sign the certificate? [y / n] : y
 #
 #
 # 1 out of 1 certificate requests certified, commit? [y / n] y
 # Wr​​ite out database with 1 new entries
 # Data Base Updated

 #
 # Create a my.cnf file that you can use to test the certificates
 #

 cat << EOF> $ DIR / my.cnf
 [client]
 ssl-ca = $ DIR / ca-cert.pem
 ssl-cert = $ DIR / client-cert.pem
 ssl-key = $ DIR / client-key.pem
 [mysqld]
 ssl-ca = $ DIR / ca-cert.pem
 ssl-cert = $ DIR / server-cert.pem
 ssl-key = $ DIR / server-key.pem
 EOF
예 3 : Windows에서 SSL 파일을 만들

Windows 용 OpenSSL이 시스템에 설치되어 있지 않은 경우는 그것을 다운로드합니다. 다음은 사용 가능한 패키지의 개요를 나타냅니다.

 http://www.slproweb.com/products/Win32OpenSSL.html

아키텍처 (32 비트 또는 64 비트)에 따라 Win32 OpenSSL Light 또는 Win64 OpenSSL Light 패키지를 선택합니다. 기본 설치 위치는 다운로드 한 패키지에 따라 C:\OpenSSL-Win32 또는 C:\OpenSSL-Win64 입니다. 다음 단계에서는 기본 위치가 C:\OpenSSL-Win32 인 것이 전제가되고 있습니다. 64 비트 패키지를 사용하는 경우에는 필요에 따라이를 변경합니다.

설정 중 「...critical component is missing: Microsoft Visual C++ 2008 Redistributables」 라는 메시지가 발생한 경우 설정을 취소하고 아키텍처 (32 비트 또는 64 비트)에 따라 다음의 패키지 중 하나를 다운로드합니다.

  • Visual C ++ 2008 Redistributables (x86) (다음 위치에서 구입 가능) :

     http://www.microsoft.com/downloads/details.aspx?familyid=9B2DA534-3E03-4391-8A4D-074B9F2BC1BF
    
  • Visual C ++ 2008 Redistributables (x64) (다음 위치에서 구입 가능) :

     http://www.microsoft.com/downloads/details.aspx?familyid=bd2a6171-e2d6-4230-b809-9a8d7548c1b6
    

추가 패키지를 설치 한 후 OpenSSL의 설정 절차를 다시 시작합니다.

설치할 때 설치 경로로 기본 C:\OpenSSL-Win32 의 상태로 기본 「Copy OpenSSL DLL files to the Windows system directory」 옵션을 선택한 상태로합니다.

설치가 완료되면 서버의 Windows 시스템 경로 변수에 C:\OpenSSL-Win32\bin 을 추가합니다.

  1. Windows 바탕 화면에서 "내 컴퓨터"아이콘을 마우스 오른쪽 클릭하여 "속성"을 선택합니다.

  2. 표시된 "시스템 등록 정보"메뉴에서 "고급"탭을 선택하고 "환경 변수"버튼을 클릭합니다.

  3. "시스템 변수"에서 "경로"를 선택한 후 "편집"버튼을 클릭합니다. "시스템 변수 편집"대화 상자가 나타납니다.

  4. 끝에 「;C:\OpenSSL-Win32\bin」 을 추가합니다 (세미콜론에주의하십시오).

  5. "OK"를 3 번​​ 누릅니다.

  6. 새로운 명령 콘솔 (Start> Run> cmd.exe)를 열고 OpenSSL을 사용할 수 있는지 확인하여 OpenSSL이 Path 변수에 제대로 통합 된 것을 확인합니다.

     Microsoft Windows [Version ...]
     Copyright (c) 2006 Microsoft Corporation. All rights reserved.
    
     C : \ Windows \ system32> cd \
    
     C : \> openssl
     OpenSSL> exit <<< If you see the OpenSSL prompt, installation was successful.
    
     C : \>
    

Windows 버전에 따라 위의 경로 설정 절차가 약간 다를 수 있습니다.

OpenSSL이 설치되면 (이 섹션의 앞부분에서 설명한) 예 1과 동일한 절차를 다음과 같이 변경하여 사용합니다.

  • 다음과 같이 Unix 명령을 변경합니다.

     # Create clean environment
     shell> rm -rf newcerts
     shell> mkdir newcerts && cd newcerts
    

    Windows에서는 대신 다음 명령을 사용합니다.

     # Create clean environment
     shell> md c:\newcerts
     shell> cd c:\newcerts
    
  • 명령 줄 끝에 「\」 문자가 나타나면이 「\」 문자를 제거하고 명령 행을 모두 한 줄로 입력해야합니다.

인증서 및 키 파일이 생성 된 후에이를 사용하여 SSL 연결을 테스트하는 방법은 섹션 6.3.10.3 "SSL 연결 사용" 을 참조하십시오.

서울시 강남구 영동대로 602 6층
TEL: 02-6061-0006  /  E: csr@mysqlkorea.com
주식회사 이노클러스터  등록번호 : 727-86-02261
Copyright © innocluster Co. ltd. all rights reserved