trino开启https
[hdfs@hadoop01 hadoop]# mkdir -p /data/ssl/ [hdfs@hadoop01 hadoop]# cd /data/ssl/
openssl req -new -x509 -keyout bd_ca_key -out bd_ca_cert -days 9999 -subj '/C=CN/ST=beijing/L=beijing/O=test/OU=test/CN=test' [hdfs@hadoop01 kerberos_https]# openssl req -new -x509 -keyout bd_ca_key -out bd_ca_cert -days 9999 -subj '/C=CN/ST=beijing/L=beijing/O=test/OU=test/CN=test' Generating a 2048 bit RSA private key .....................................................................................................+++ .+++ writing new private key to 'bd_ca_key' Enter PEM pass phrase: Verifying - Enter PEM pass phrase: ----- [hdfs@hadoop01 kerberos_https]# [hdfs@hadoop01 kerberos_https]# # (输入密码和确认密码是123456,此命令成功后输出bd_ca_key和bd_ca_cert两个文件) [hdfs@hadoop01 kerberos_https]# ll 总用量 8 -rw-r--r-- 1 root root 1294 3月 27 19:36 bd_ca_cert -rw-r--r-- 1 root root 1834 3月 27 19:36 bd_ca_key
scp -r /opt/security/kerberos_https root@hadoop02 : /opt/security/
cd /opt/security/kerberos_https # 所有需要输入密码的地方全部输入123456(方便起见,如果你对密码有要求请自行修改) # 1 输入密码和确认密码:123456,此命令成功后输出keystore文件 keytool -keystore keystore -alias localhost -validity 9999 -genkey -keyalg RSA -keysize 2048 -dname "CN=test, OU=test, O=test, L=beijing, ST=beijing, C=CN" # 2 输入密码和确认密码:123456,提示是否信任证书:输入yes,此命令成功后输出truststore文件 keytool -keystore truststore -alias CARoot -import -file bd_ca_cert # 3 输入密码和确认密码:123456,此命令成功后输出cert文件 keytool -certreq -alias localhost -keystore keystore -file cert # 4 此命令成功后输出cert_signed文件 openssl x509 -req -CA bd_ca_cert -CAkey bd_ca_key -in cert -out cert_signed -days 9999 -CAcreateserial -passin pass:123456 # 5 输入密码和确认密码:123456,是否信任证书,输入yes,此命令成功后更新keystore文件 keytool -keystore keystore -alias CARoot -import -file bd_ca_cert # 6 输入密码和确认密码:123456 keytool -keystore keystore -alias localhost -import -file cert_signed 最终得到: -rw-r--r-- 1 root root 1294 3月 27 19:36 bd_ca_cert -rw-r--r-- 1 root root 17 3月 27 19:43 bd_ca_cert.srl -rw-r--r-- 1 root root 1834 3月 27 19:36 bd_ca_key -rw-r--r-- 1 root root 1081 3月 27 19:43 cert -rw-r--r-- 1 root root 1176 3月 27 19:43 cert_signed -rw-r--r-- 1 root root 4055 3月 27 19:43 keystore -rw-r--r-- 1 root root 978 3月 27 19:42 truststore
keytool -importkeystore -srckeystore ./keystore -destkeystore .
cp ./truststore ./truststore.jks
[root@devops-hadoop3-krb-node2 hdfs_ca]# keytool -list -v -keystore ./keystore 输入密钥库口令: 密钥库类型: JKS 密钥库提供方: SUN 您的密钥库包含 2 个条目 别名: caroot 创建日期: 2023-10-7 条目类型: trustedCertEntry 所有者: CN=devops-hadoop3-krb-node1, OU=dtstack, O=dtstack, L=hangzhou, ST=zhejiang, C=CN 发布者: CN=devops-hadoop3-krb-node1, OU=dtstack, O=dtstack, L=hangzhou, ST=zhejiang, C=CN 序列号: f9ed82c1408b00c7 有效期开始日期: Sat Oct 07 15:52:51 CST 2023, 截止日期: Tue Feb 21 15:52:51 CST 2051 证书指纹: MD5: 15:D6:D6:37:13:8E:22:0D:15:C9:C1:A2:6A:F3:EC:B5 SHA1: 80:23:0B:D9:4C:99:D1:10:2A:60:59:C4:9A:F9:A3:9E:B8:04:AC:87 SHA256: 44:AD:10:20:D0:34:32:62:F9:3C:9C:DF:C4:EA:58:C8:08:BB:50:DD:5A:D8:0F:18:AD:D4:A0:3E:CA:D0:3C:38 签名算法名称: SHA256withRSA 版本: 3
上述生成的https证书存在安全问题,在使用其他客户端使用jdbc来连接trino时,会报错证书的安全问题导致无法连接,因此,可以采用以下的证书生成方式:
kyotom@ditto-2:~/key$ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes .+.....+.+.........+..+...+....+..+......+.......+...+.....+..........+.....+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.+......+...+..+...+.+..+....+......+...+......+...............+.........+..+...+......+...+.......+...........+.......+.....+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*......+...+...+.....+......+.+..+.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ......+...........+.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.....+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*..+..+...+....+..+.+..+...+....+..........................+.............+......+.....+....+.........+..+.+..+.............+....................+....+.....+....+......+.........+..+.............+......+........+.+............+...............+...+.........+..+....+......+...+......+....................+.........+............+.+.....+...+..................................+..+...+.+..+....+...........+....+........+..........+.................+.+.......................+.+...+......+.....+....+..+...............+..................+..........+..........................+......+.+..............+......+.......+.....+.+.................+.......+...+...+......+......+..+............+.+...+.....+.+.................................+.....+............+..................+...+.......+..................+..+......+.+........+..........+...........+..........+.....................+...........+....+.....+...+..................+...................+......+.....+...+.........+................+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]:CN State or Province Name (full name) [Some-State]:ZJ Locality Name (eg, city) []:HZ Organization Name (eg, company) [Internet Widgits Pty Ltd]:dtstack Organizational Unit Name (eg, section) []:engine Common Name (e.g. server FQDN or YOUR name) []:ditto-1/ditto-2 Email Address []:zhenlu@dtstack.com
kyotom@ditto-2:~/key$ openssl pkcs12 -export -in cert.pem -inkey key.pem -out cert.pfx -name "ditto-1"/"ditto-2" Enter Export Password: Verifying - Enter Export Password:
kyotom@ditto-1:~/key$ keytool -importkeystore -srckeystore cert.pfx -destkeystore keystore.jks -srcstoretype PKCS12 -deststoretype JKS -alias "ditto-1"/"ditto-2" Importing keystore cert.pfx to keystore.jks... Enter destination keystore password: Re-enter new password: Enter source keystore password:
truststore 的密码为了简单我们依旧使用 abc123 作为密码。 kyotom@ditto-1:~/key$ keytool -importkeystore -srckeystore keystore.jks -destkeystore truststore.jks -srcalias ditto-1/ditto-2 -destalias ditto-1/ditto-2 -srcstoretype JKS -deststoretype JKS Importing keystore keystore.jks to truststore.jks... Enter destination keystore password: Re-enter new password: Enter source keystore password: Warning: The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format using "keytool -importkeystore -srckeystore truststore.jks -destkeystore truststore.jks -deststoretype pkcs12".
http-server.https.enabled=true http-server.https.port=8443 http-server.https.keystore.path=/data/kerberos/hdfs_ca/keystore http-server.https.keystore.key=abc123 http-server.authentication.allow-insecure-over-http=false #http-server.https.keymanager.password=abc123 #http-server.https.truststore.path=/data/kerberos/hdfs_ca/truststore #http-server.https.truststore.key=abc123 internal-communication.shared-secret=abc123 http-server.authentication.type=PASSWORD #为Trino coordinator 启用密码认证类型。必须设置为PASSWORD。
http-server.https.enabled=true http-server.https.port=8443 http-server.https.keystore.path=/data/kerberos/hdfs_ca/keystore http-server.https.keystore.key=abc123 http-server.authentication.allow-insecure-over-http=false internal-communication.shared-secret=abc123