---
schema_version: "1"
id: 963864fa0f4988c97be6834d18a41a27cde5a661e71f1e74249fa528df188290
title: 需要 SSL 的 Oracle JDBC 連線
collection: tableau
version: current
locale: zh-tw
portal_url: https://docs.salesforce.com/tableau/current/zh-tw/pro/desktop/jdbc_oracle_ssl_config.md
canonical_url: https://help.tableau.com/current/pro/desktop/zh-tw/jdbc_oracle_ssl_config.htm
source_site: help.tableau.com
content_type: documentation
content_hash: 24b4905bf2341af8ba9825f676f96b5a9e708701eef6b481161a31e72aed5792
description: Configure one-way and two-way SSL for Oracle JDBC connections in Tableau.
---
[跳至主要內容](#main-content)

# 需要 SSL 的 Oracle JDBC 連線

如果您要連線至 SSL（安全通訊端層）伺服器，請勾選**「需要 SSL」**核取方塊。

從 2020.2 版起，Oracle 使用 JDBC 連接器。如果您將 Oracle 資料來源設為使用 SSL 單向或雙向驗證，您可以加入適當認證和/或金鑰來連線。

## 需要 SSL

如果連線需要 SSL，請執行下列動作︰

1. 在連接器對話方塊中按一下「需要 SSL」。
    
    ![設定 SSL 憑證對話方塊，其中提示選取公用 SSL 憑證。 ](/tableau/current/zh-tw/pro/desktop/zh-tw/Img/examples_oracle_req_ssl.png)
2. 請根據情況為連線設定 SSL︰
    - 如果使用自我簽署憑證或由私人憑證授權單位 (CA) 簽署的憑證，則可能需要為單向 SSL 連線設定信任。[請參閱「為 Oracle 設定單向 SSL」](#Configur)。
    - 如果使用雙向 SSL，則需要設定用戶端金鑰。請參閱[「設定雙向 SSL」](#Configur2)。

## 為 Oracle 設定單向 SSL

若要為伺服器憑證設定信任，請在此處參閱 JDBC 連接器的一般說明︰[「為 JDBC 連線設定單向 SSL」](https://help.tableau.com/current/pro/desktop/zh-tw/jdbc_ssl_config.htm)。

如果您決定使用屬性檔案來設定信任，則請將 Oracle JDBC 驅動程式的屬性設定如下。

javax.net.ssl.trustStore=C:\\\\My\_Folder\\\\truststore.jks  
javax.net.ssl.trustStoreType=JKS  
javax.net.ssl.trustStorePassword=_password_

**附註：**如要將工作簿發佈到 Tableau Server，Tableau Desktop 和 Tableau Server 兩者的電腦均需要有 Oracle 屬性檔案和 truststore.jks 檔案的副本。

## 設定雙向 SSL

設定 Oracle 連線的雙向 SSL 支援有兩種選項：

- [在資料來源中內嵌用戶端憑證與私密金鑰](#Embed)
- [使用屬性檔案設定用戶端憑證與私密金鑰](#Properties)

### 選項 1︰在資料來源中內嵌用戶端憑證與私密金鑰

若要內嵌 SSL 憑證、用戶端憑證與用戶端金鑰︰

1. 如有必要，請按照[為 Oracle 設定單向 SSL](#Configur)中的步驟設定伺服器信任。
2. 按一下**「用戶端憑證 >>」**。
    
    ![設定 SSL 憑證對話方塊，其中提示選取公用 SSL 憑證。 ](/tableau/current/zh-tw/pro/desktop/zh-tw/Img/examples_oracle_req_ssl.png)
3. 指定用戶端憑證和用戶端金鑰的位置。  
    憑證與私密金鑰應採用未加密的 PEM 格式。有關轉換為正確格式的建議，請參閱本文件後面的說明。
    
    ![設定 SSL 憑證對話方塊，其中提示選取公用 SSL 憑證。  選取自訂 SSL 憑證選項，並且遊標位於用戶端認證欄位。](/tableau/current/zh-tw/pro/desktop/zh-tw/Img/examples_oracle_ssl_cert_294x244.png)

### 選項 2︰使用屬性檔案設定用戶端憑證與私密金鑰

若要使用屬性檔案設定憑證與金鑰︰

1. 修改 oracle.properties 檔案以反映金鑰存放區和信任存放區設定。以下列範例為例。請務必取代檔案所在位置的「My\_Folder」，以及以自己的密碼取代「<password>」。OSX 和 Linux 上的路徑只需要一個「/」進行分隔。
    
    javax.net.ssl.trustStore=C:\\\\My\_Folder\\\\truststore.jks  
    javax.net.ssl.trustStoreType=JKS  
    javax.net.ssl.trustStorePassword=<password>  
    javax.net.ssl.keyStore=C:\\\\My\_Folder\\\\keystore.jks  
    javax.net.ssl.keyStoreType=JKS  
    javax.net.ssl.keyStorePassword=_password_
2. 將 oracle.properties 儲存到 <Document>\\MyTableau Respository\\Datasources 資料夾。
3. 將 oracle.properties、truststore.jks 和 keystore.jks 複製到 Tableau Server 電腦。這樣一來，工作簿就會發佈到 Tableau Server。

如果使用此方法，您就不必經由 SSL 對話方塊上傳憑證和金鑰。反之，只需按一下「**需要 SSL**」。這樣 Oracle JDBC 連接器就會從 oracle.properties 檔案讀取金鑰存放區和信任存放區的位置。

### 發佈工作簿

若要將工作簿發佈到 Tableau Server，請確認以下條件皆符合：

- 若使用屬性檔案，Tableau Desktop 和 Tableau Server 兩者的電腦均有相同 Oracle 屬性檔案、truststore.jks 和 keystore.jks 的副本。
- 伺服器將相同 Oracle JDBC 連接器視為 Tableau Desktop 電腦來使用。
- 若已使用[「內嵌」](#Embed)選項，請在發佈時選取「內嵌密碼」選項。

## 轉換金鑰格式

儲存 SSL 金鑰的格式有多種，包括︰

- Oracle Wallet
- JKS - 若要使用屬性檔案設定 SSL 信任，請使用此格式。
- PEM - 若要使用 Tableau 介面在資料來源中內嵌金鑰，請使用此格式。

以下是一些建議輸入的命令，您可以在命令列提示字元中輸入，以將金鑰轉換為正確的格式。有關詳細資訊，請參閱 Oracle 文件。

若要將伺服器憑證從 Oracle Wallet 匯出至 PEM 檔案︰

orapki wallet export -wallet wallet\_location -dn certificate\_dn -cert output\_certificate\_filename.pem

若要將伺服器憑證與用戶端金鑰從 Oracle Wallet 匯出至 JKS︰

orapki wallet pkcs12\_to\_jks -wallet ./-pwd mypasswd -jksKeyStoreLoc ./ewalletK.jks -jksKeyStorepwd _password_ -jksTrustStoreLoc ./ewalletT.jks -jksTrustStorepwd _password_

若要使用金鑰工具與 OpenSSL 將伺服器憑證從 JKS 信任存放區匯出至 PEM 檔案︰

1. 將 JKS 格式匯出為 PKCS12 格式︰
    
    keytool -importkeystore -srckeystore truststore.jks -destkeystore truststore.p12 -srcstoretype JKS -deststoretype PKCS12 -srcstorepass "_password_" -deststorepass "_password_"
2. 從 PKCS12 取得 PEM 檔案：
    
    openssl pkcs12 -in truststore.p12 -out serverca.pem

若要使用金鑰工具與 OpenSSL 將伺服器憑證與用戶端金鑰從 JKS 信任存放區匯出至 PEM 檔案︰

1. 將憑證從信任存放區匯出如下。
    1. 將 JKS 格式匯出為 PKCS12 格式︰
        
        keytool -importkeystore -srckeystore truststore.jks -destkeystore truststore.p12 -srcstoretype JKS -deststoretype PKCS12 -srcstorepass "_password_" -deststorepass "_password_"
    2. 從 PKCS12 取得 PEM 檔案：
        
        openssl pkcs12 -in truststore.p12 -out serverca.pem
2. 將用戶端金鑰與用戶端憑證從金鑰存放區匯出如下。
    1. 使用金鑰工具將 JKS 格式轉換為 PCKS12 格式：
        
        keytool.exe -importkeystore -srckeystore keystore.jks -destkeystore keystore.p12 -srcstoretype JKS -deststoretype PKCS12 -srcstorepass "_password_" -deststorepass "_password_"
    2. 使用 OpenSSL 匯出用戶端憑證：
        
        openssl pkcs12 -in keystore.p12 -nokeys -out clientcert.pem
    3. 使用 OpenSSL 匯出用戶端金鑰：
        
        openssl pkcs12 -in keystore.p12 -nocerts -out clientkeyEncrypted.pem
    4. 使用 OpenSSL 將加密版本轉換為 PKCS8 格式：
        
        openssl pkcs8 -topk8 -nocrypt -in clientkeyEncrypted.pem -out clientkey.pem

### 另請參閱

- [設定用於 JDBC 連線的 SSL](https://help.tableau.com/current/pro/desktop/zh-tw/jdbc_ssl_config.htm) - 有關為 JDBC 連線安裝受信任的 SSL 憑證的更多一般資訊。