> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-revert-104359-revert-104251-parquet-single.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# ClickHouse의 SSL 인증서 검증 오류 해결

> SSL Exception CERTIFICATE_VERIFY_FAILED 오류를 해결하는 방법을 알아봅니다.

<div id="resolving-ssl-certificate-verify-error-in-clickhouse">
  ## ClickHouse에서 코드 210 SSL 인증서 검증 오류 해결
</div>

이 오류는 일반적으로 다음과 같이 표시됩니다.

`Code: 210. DB::NetException: SSL Exception: error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED`

<div id="cause-of-the-error">
  ## 오류의 원인
</div>

이 오류는 `clickhouse-client`를 사용해 ClickHouse 서버에 연결하려고 할 때 발생합니다. 오류의 원인은 다음 중 하나입니다.

* 클라이언트 설정 파일 `config.xml`에 시스템의 기본 CA 저장소에 있는 루트 인증서가 없거나
* 자체 서명 인증서 또는 내부 CA 인증서가 구성되어 있지 않음

<div id="solution">
  ## 해결 방법
</div>

내부 CA 또는 자체 서명된 CA를 사용하는 경우, 클라이언트 디렉터리(예: `/etc/clickhouse-client`)의 `config.xml`에서 CA 루트 인증서를 구성하고 기본 위치에 있는 기본 루트 CA 인증서의 로드를 비활성화합니다.

다음은 예시 구성입니다:

```xml theme={null}
<openSSL>
    <client>
        <loadDefaultCAFile>false</loadDefaultCAFile>
        <caConfig>/etc/clickhouse-server/certs/marsnet_ca.crt</caConfig>
        <cacheSessions>true</cacheSessions>
        <disableProtocols>sslv2,sslv3</disableProtocols>
        <preferServerCiphers>true</preferServerCiphers>
        <invalidCertificateHandler>
            <name>RejectCertificateHandler</name>
        </invalidCertificateHandler>
    </client>
</openSSL>
```

<div id="python-clients-on-macos">
  ## macOS의 Python 클라이언트
</div>

Python 클라이언트는 일반적으로 이 오류를 다음과 같이 보고합니다:

`ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate`

macOS에서는 python.org에서 제공하는 Python build가 시스템 키체인이 아니라 OpenSSL의 기본 경로를 통해 인증서를 검증합니다. 새로 설치한 경우, 해당 경로는 루트 인증서 번들을 가리키지 않습니다. 설치 프로그램에는 [certifi](https://pypi.org/project/certifi/)가 포함되어 있지만, 함께 제공되는 `Install Certificates.command` script를 실행하기 전까지는 이를 OpenSSL의 기본 위치에 연결하지 않습니다. 따라서 해당 인증서가 유효하더라도 그전까지는 클라이언트가 ClickHouse Cloud 서버 인증서를 검증할 수 없습니다. 이 문제는 Python 3.11에만 해당하는 것이 아니라, python.org의 macOS build 전반(Python 3.6 이상)에 영향을 줍니다.

`Install Certificates.command`를 실행하여 certifi를 OpenSSL의 기본 인증서 경로에 연결하십시오. 경로에 있는 버전은 설치한 버전에 맞게 조정하십시오:

```bash theme={null}
open "/Applications/Python 3.11/Install Certificates.command"
```

또는 클라이언트가 certifi 번들을 직접 사용하도록 지정할 수 있습니다. [ClickHouse Connect](/ko/integrations/language-clients/python/index)는 자동으로 certifi로 폴백되지 않으므로 번들을 `ca_cert` 매개변수로 전달하십시오:

```python theme={null}
import certifi
import clickhouse_connect

client = clickhouse_connect.get_client(
    host='HOSTNAME.clickhouse.cloud',
    port=8443,
    username='default',
    password='YOUR_SECRET_PASSWORD',
    ca_cert=certifi.where(),
)
```

<div id="additional-resources">
  ## 추가 자료
</div>

[`clickhouse-client` 구성 문서](/ko/concepts/features/interfaces/client#configuration_files)를 참조하십시오.
