# 21.12. Certificate Authentication

此身份驗證方法使用 SSL 用戶端憑證進行身份驗證。因此，它僅適用於 SSL 連線。使用此身份驗證方法時，伺服器將要求用戶端提供有效可信任的憑證。不會有密碼提示發送給用戶端。憑證的 cn（Common Name）屬性將與請求連線的資料庫使用者名稱進行比較，如果符合，則允許登入。使用者名稱對應可用於允許 cn 與資料庫使用者名稱不同。

SSL 憑證身份驗證支援以下配置選項：

`map`

允許在系統使用者名稱和資料庫使用者名稱之間進行對應。相關詳細資訊，請參閱[第 21.2 節](/16/server-administration/client-authentication/user-name-maps.md)。

在指定憑證認證的 pg\_hba.conf 記錄中，憑證選項 clientcert 被假設為 verify-ca 或 verify-full，由於此方法需要用戶端憑證，因此無法將其關閉。 cert 方法增加了基本 clientcert 憑證有效性測試的方法是檢查 cn 屬性是否與資料庫使用者名稱相符。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.postgresql.tw/16/server-administration/client-authentication/certificate-authentication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
