# 设置根证书授权链

Talend Administration Center webserver 和客户端应用程序 (Studio、Nexus/artifactory、GIT 等) 之间的安全HTTPS连接可以通过提供通用认证以及10年以上长期认证的证书链实现。

## 步骤

1. 按照不同的子步骤生成 .cer 证书文件:
   1. 根据你的配置准备以下数值:
      * 服务器 IP: serverIP
      * SAN IP: serverIP 或附加域名 (如有)
      * 密钥库密码: changeit
      * 服务器 Pretty Name: serverPrettyName
   2. 在Powershell中，采用适当的值生成私钥。

      keytool -genkey -alias serverIP -keyalg RSA -keysize 4096 -keystore talendKey.jks -dname "CN=serverIP, OU=name of the organizational unit/department, O=name of the company/organization, ST=name of the region or state , C=name of the country" -keypass changeit -storepass changeit -ext SAN=ip:serverIP,dns:serverPrettyName
   3. 采用适当的值执行证书签署请求，来获得 .csr 文件。

      keytool -certreq -file serverIP.csr -keystore talendKey.jks -storepass changeit -alias serverIP -ext SAN=ip:serverIP,dns:serverPrettyName
   4. 使用证书颁发机构对 .csr 文件进行副署。
   5. 下载OpenSSL格式的认可证书。
   6. 从上述文件中提取出第一个证书内容，将其通过文本编辑工具粘贴到 serverIP.cer 文件中。
   7. 证书链有变化或首次安装的情况下，需要将证书导入到 Truststore。

      从 serverIP.cer文件中提取出第一个服务器关联条目，将其粘贴到 chain.cer文件中。证书链应包含根签名证书和中间签名证书。keytool -import -file /opt/talend/talend-version/truststore/Talend\_certificate/chain.cer -keystore /opt/talend/talend-version/truststore/BitTalend -alias chain

      信息注释提示： 如果你设置的是自签名证书，而非证书颁发机构的通用证书，可以先将所有证书导入，然后使用证书链来初始化 Java Keystore。更多信息，请参阅相关的 [为 Talend Administration Center 配置 SSL](https://help.qlik.com/talend/en-US/installation-guide-windows/8.0/config-ssl-for-tac) 一节。
2. 将下载好的 serverIP.cer 文件与当前在JKS商店中可用的 p12 格式密钥文件进行合并。
   1. 用 Keytool 将 JKS 转换为 PKCS 格式: keytool -importkeystore -srckeystore talendKey.jks -destkeystore talendKey.p12 -deststoretype PKCS12
   2. 从 PKCS 中提取密钥文件，随后创建一个单独的密钥文件: openssl pkcs12 -in talendKey.p12 -nodes -nocerts -out talendKey.key
3. 将证书、密钥文件和证书链合并成一个新的 p12 文件:

   openssl pkcs12 -export -in &lt;serverIP&gt;.cer -inkey talendKey.key -out certificate.p12 -chain -CAfile chain.cer -name &lt;serverIp&gt;
4. 用 Java Keytool 将 p12 文件转换为 Keystore

   Nexus: keytool -importkeystore -srckeystore certificate.p12 -srcstoretype PKCS12 -destkeystore keystore

   Talend Administration Center:keytool -importkeystore -srckeystore certificate.p12 -srcstoretype PKCS12 -destkeystore /opt/talend/talend-version/truststore/BitTalend
5. 如果您在使用 Nexus，请将生成的 Keystore (和 Truststore) 存储在 nexusinstall&gt;etc&gt;ssl 子文件夹中。请停止Nexus并重启，以应用刚才的修改。
6. 请确保您的键名称以及密码在 etc/jetty/jetty-https.xml 文件中正确无误。
7. 如何配置 SSL 连接:
   * 如果证书设置在了 Tomcat webserver 上，输入以下命令: /opt/talend/talend-version/truststore/Talend\_SSL/Talend\_TAC\_QA" keystorePass="keystore pass"。

     随后配置 Tomcat: 打开 &lt;TomcatPath&gt;/conf/server.xml 文件，取消注释并编辑SSL部分，如下所示:
     ```
     <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
                    maxThreads="150" scheme="https" secure="true"
                    clientAuth="true" sslProtocol="TLS" 
     	keystoreFile="<SSLFolderPath/serverKeystore.jks" 
     	keystorePass=<keystorePassword>
     	truststoreFile="<SSLFolderPath/serverTruststore.jks" 
     	truststorePass=<trustStorePassword> />
     ```
   * 如果证书只设置在了 webapp 本身，请参阅[定义到其它应用的 SSL 连接](https://help.qlik.com/talend/zh-CN/installation-guide-linux/8.0/defining-ssl-connection "在 Talend Administration Center 中配置到其它应用的安全连接（SSL/TLS）时，您需要在 configuration.properties 文件中指定 keystore.path、keystore.password、truststore.path 及 truststore.password 参数。")并输入以下命令：keytool -delete -alias tomcat -keystore /opt/talend/talend-version/truststore/BitTalend -storepass changeit

## 结果

重新启动 Talend Administration Center 服务。

浏览器中输入 Talend Administration Center URL: https://localhost:8080/org.talend.administrator。该应用程序现在与绿锁图标同时显示：![Padlock](https://help.qlik.com/talend/zh-CN/installation-guide-linux/Resources/images/SSL_CA_green_padlock.png)。