Join us Sept 17 at .local NYC! Use code WEB50 to save 50% on tickets. Learn more >
MongoDB Event
Docs Menu
Docs Home
/ / /
C 드라이버
/ /

TLS 구성

URI에 tls=true 를 포함하여 TLS를 사용하도록 설정합니다.

mongoc_uri_t *uri = mongoc_uri_new ("mongodb://localhost:27017/");
mongoc_uri_set_option_as_bool (uri, MONGOC_URI_TLS, true);
mongoc_client_t *client = mongoc_client_new_from_uri (uri);

다음 URI 옵션을 사용하여 TLS를 추가로 구성할 수 있습니다.

상수
설명

MONGOC_URI_TLS

TLS

{true|false}는 TLS를 사용해야 하는지 여부를 나타냅니다.

MONGOC_URI_TLSCERTIFICATEKEYFILE

tlscertificatekeyfile

공개 인증서가 끝에 연결된 PEM 형식의 비공개 키의 경로입니다.

MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD

tlscertificatekeypassword

암호화됨 비공개 키의 잠금을 해제하는 데 사용할 비밀번호(있는 경우)입니다.

MONGOC_URI_TLSCAFILE

tlsCAFile

신뢰할 수 있는 것으로 간주되어야 하는 인증 기관 한 개 또는 번들입니다.

MONGOC_URI_TLSALLOWINVALIDCERTIFICATES

tlsAllowInvalidCertificates

인증서 확인 오류 수락 및 무시(예: 신뢰할 수 없는 발급자, 만료 등)

MONGOC_URI_TLSALLOWINVALIDHOSTNAMES

tlsAllowInvalidHostnames

인증서의 호스트 이름 확인을 무시합니다(예: 중간자(Man In The Middle), 유효한 인증서를 사용하지만 다른 호스트 이름으로 발급됨)

MONGOC_URI_TLSINSECURE

tlsInsecure

{true|false}는 안전하지 않은 TLS 옵션을 사용해야 하는지 여부를 나타냅니다. 현재 이는 MongOC_URI_TLSALLOWINVALIDCERTIFICATES 및 MongOC_URI_TLSALLOWINVALIDHOSTNAMES를 의미합니다.

MONGOC_URI_TLSDISABLECERTIFICATEREVOCATIONCHECK

tlsdisablecertificatereventioncheck

{true|false}는 철회 확인(CRL / OCSP)을 비활성화할지 여부를 나타냅니다.

MONGOC_URI_TLSDISABLEOCSPENDPOINTCHECK

tlsdisableocspendpointcheck

{true|false}는 OCSP 응답이 스테이플링되지 않은 경우 OCSP 응답자 엔드포인트를 요청하지 않아야 하는지 여부를 나타냅니다.

Alternatively, the mongoc_ssl_opt_t struct may be used to configure TLS with mongoc_client_set_ssl_opts or mongoc_client_pool_set_ssl_opts. Most of the configurable options can be set using the Connection String URI.

mongoc_ssl_opt_t key
URI 키
pem_file
tlsClientCertificateKeyFile

pem_pwd

tlsClientCertificateKeyPassword

ca_file
tlsCAFile

weak_cert_validation

tlsAllowInvalidCertificates

allow_invalid_hostname
tlsAllowInvalidHostnames

The only exclusions are crl_file and ca_dir. Those may only be set with mongoc_ssl_opt_t.

TLS가 활성화된 상태에서 MongoDB 를 시작하는 경우, 기본값 클라이언트 는 --tlsCAFile 에서 지정한 인증 기관에서 발급한 클라이언트 인증서 또는 서버 에서 사용 중인 네이티브 인증서 저장 가 신뢰하는 기관을 제공해야 합니다.

클라이언트 인증서를 제공하려면 URI의 tlsCertificateKeyFile 를 PEM 아머드 인증서 파일 로 설정하다 합니다.

mongoc_uri_t *uri = mongoc_uri_new ("mongodb://localhost:27017/");
mongoc_uri_set_option_as_bool (uri, MONGOC_URI_TLS, true);
mongoc_uri_set_option_as_utf8 (uri, MONGOC_URI_TLSCERTIFICATEKEYFILE, "/path/to/client-certificate.pem");
mongoc_client_t *client = mongoc_client_new_from_uri (uri);

MongoDB C 드라이버 는 구성된 인증 기관에서 발급한 서버 인증서의 유효성 검사, 호스트 이름 유효성 검사 및 만료를 자동으로 확인합니다.

이 동작을 덮어쓰려면 호스트 이름 유효성 검사, OCSP 엔드포인트 해지 확인, 해지 확인을 완전히 비활성화하고 유효하지 않은 인증서를 허용할 수 있습니다.

이 동작은 tlsAllowInvalidHostnames, tlsDisableOCSPEndpointCheck, tlsDisableCertificateRevocationChecktlsAllowInvalidCertificates 옵션을 각각 사용하여 제어합니다. 기본적으로 모두 false 로 설정됩니다.

이러한 기본값을 변경하는 것은 클라이언트 가 중간자 공격( tlsAllowInvalidHostnames 이 설정하다 경우), 유효하지 않은 인증서( tlsAllowInvalidCertificates 가 설정하다 경우) 또는 잠재적으로 해지된 인증서( tlsDisableOCSPEndpointCheck 또는 tlsDisableCertificateRevocationCheck 2}의 경우)에 노출될 수 있으므로 권장되지 않습니다. 이 설정하다).

기본값 으로 libmongoc은 지원되는 TLS 라이브러리를 찾고 TLS 지원 을 활성화 하려고 시도합니다. 이는 기본값 AUTO 로 설정하다 되는 cmake 플래그 ENABLE_SSL 에 의해 제어됩니다. 유효한 값은 다음과 같습니다.

  • AUTO 기본값 동작. 시스템의 네이티브 TLS 라이브러리에 연결하거나 OpenSSL을 찾습니다.

  • DARWIN 링크를 macOS의 네이티브 TLS 라이브러리인 보안 전송에 연결합니다.

  • WINDOWS Windows의 네이티브 TLS 라이브러리인 보안 채널에 대한 링크입니다.

  • OPENSSL OpenSSL(libssl)에 대한 링크입니다. 선택적 설치 경로는 OPENSSL_ROOT 으로 지정할 수 있습니다.

  • LIBRESSL LibreSSL의 libtls에 대한 링크입니다. (LibreSSL의 호환되는 libssl은 OPENSSL 을(를) 설정하여 연결할 수 있습니다).

  • OFF TLS 지원 을 비활성화합니다.

MongoDB C 드라이버는 Linux 및 Unix 플랫폼(macOS 제외)에서 OpenSSL(사용 가능한 경우)을 사용합니다. 업계 권장사항 및 일부 규정에서는 TLS 1.1 이상을 사용해야 하며, 이를 위해서는 OpenSSL 1.0.1 이상이 필요합니다. 다음과 같이 OpenSSL 버전을 확인합니다.

$ openssl version

시스템의 OpenSSL이 최신 버전인지(최소 1.0.1) 확인하거나 비시스템 경로에 최신 버전을 설치하고 다음을 사용하여 빌드합니다.

cmake -DOPENSSL_ROOT_DIR=/absolute/path/to/openssl

OpenSSL에 대해 컴파일할 때 운전자 배포판에 구성된 대로 시스템 기본값 인증서 저장 로드하려고 시도합니다. 이는 tlsCAFile URI 옵션을 설정하거나 ca_file ca_dir mongoc_ssl_opt_t의 및필드를 사용하여 재정의할 수 있습니다.

The Online Certificate Status Protocol (OCSP) (see RFC 6960) is fully supported when using OpenSSL 1.0.1+ with the following notes:

  • When a crl_file is set with mongoc_ssl_opt_t, and the crl_file revokes the server's certificate, the certificate is considered revoked (even if the certificate has a valid stapled OCSP response)

MongoDB C 드라이버 는 openssl 에 대해 컴파일하도록 구성된 경우 OpenSSL 호환성 검사를 사용하여 LibreSSL을 지원합니다. 또한 libressl 에 대해 빌드 하도록 구성된 경우 새로운 libtls 라이브러리를 지원합니다.

When compiled against the Windows native libraries, the crl_file option of a mongoc_ssl_opt_t is not supported, and will issue an error if used.

tlsDisableOCSPEndpointChecktlsDisableCertificateRevocationCheck 를 설정해도 아무런 효과가 없습니다.

The Online Certificate Status Protocol (OCSP) (see RFC 6960) is partially supported with the following notes:

  • The Must-Staple extension (see RFC 7633) is ignored. Connection may continue if a

  • 필수 필수 인증서는 스테이플링된 응답 없이 제공됩니다( 클라이언트 가 OCSP 응답자로부터 해지된 응답을 받지 않는 경우).

  • 필수 필수 인증서가 스테이플 응답 없이 제시되고 OCSP 응답자가 다운된 경우 연결이 계속됩니다.

MongoDB C 드라이버 는 Windows 네이티브 TLS 라이브러리(보안 채널 또는 SChannel) 및 해당 네이티브 암호화 라이브러리(Cryptgraphy API: Next Generation, 또는 CNG)를 지원합니다.

When compiled against the Windows native libraries, the ca_dir option of a mongoc_ssl_opt_t is not supported, and will issue an error if used.

암호화된 PEM 파일(예: tlsCertificateKeyPassword 설정)도 지원되지 않으며, 이를 로드하려고 하면 오류가 발생합니다.

tlsCAFile 설정하다 하면 운전자 는 제공된 기관에서 발급한 서버 인증서만 허용합니다. tlsCAFile 이(가) 설정하다 되지 않은 경우 운전자 는 System Local Machine Root 인증서 저장 를 사용하여 인증 기관을 조회하여 제공된 인증서를 확인합니다.

When crl_file is set with mongoc_ssl_opt_t, the driver will import the revocation list to the System Local Machine Root certificate store.

tlsDisableOCSPEndpointCheck 을(를) 설정해도 아무런 효과가 없습니다.

The Online Certificate Status Protocol (OCSP) (see RFC 6960) is partially supported with the following notes:

  • The Must-Staple extension (see RFC 7633) is ignored. Connection may continue if a Must-Staple certificate is presented with no stapled response (unless the client receives a revoked response from an OCSP responder).

  • When a crl_file is set with mongoc_ssl_opt_t, and the crl_file revokes the server's certificate, the OCSP response takes precedence. E.g. if the server presents a certificate with a valid stapled OCSP response, the certificate is considered valid even if the crl_file marks it as revoked.

  • 필수 필수 인증서가 스테이플 응답 없이 제시되고 OCSP 응답자가 다운된 경우 연결이 계속됩니다.

MongoDB C 드라이버는 Darwin(OS X, macOS, iOS 등) 네이티브 TLS 라이브러리(Secure Transport) 및 네이티브 암호화 라이브러리(Common Crypto, 또는 CC)를 지원합니다.

보안 전송에 대해 컴파일할 때는 ca_dir crl_file mongoc_ssl_opt_t의 및 옵션이 지원되지 않습니다. 둘 중 하나를 사용하면 오류가 발생합니다.

tlsCAFile 설정하다 하면 운전자 는 제공된 기관에서 발급한 서버 인증서만 허용합니다. tlsCAFile 이(가) 설정하다 되지 않으면 운전자 는 현재 잠금 해제된 키체인의 인증 기관을 사용합니다.

tlsDisableOCSPEndpointChecktlsDisableCertificateRevocationCheck 를 설정해도 아무런 효과가 없습니다.

The Online Certificate Status Protocol (OCSP) (see RFC 6960) is partially supported with the following notes.

  • The Must-Staple extension (see RFC 7633) is ignored. Connection may continue if a Must-Staple certificate is presented with no stapled response (unless the client receives a revoked response from an OCSP responder).

  • 필수 필수 인증서가 스테이플 응답 없이 제시되고 OCSP 응답자가 다운된 경우 연결이 계속됩니다.

돌아가기

가이드

이 페이지의 내용