반응형
Notice
Recent Posts
Recent Comments
Link
지구정복
[Trino] SSL/TLS(https) 적용 혹은 만료시 재생성후 배포 | Max retries exceeded with url 본문
데이터 엔지니어링 정복/Trino
[Trino] SSL/TLS(https) 적용 혹은 만료시 재생성후 배포 | Max retries exceeded with url
noohhee 2025. 2. 13. 16:14728x90
반응형
현재 trino를 password인증 방식을 사용중이고 ssl/tls 설정을 하여 https로 trino를 사용중인데 아래와 같은 에러가 발생했다.
HTTPSConnectionPool(host='mycluster00', port=9998): Max retries exceeded with url: /v1/statement (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1091)')))
인증서가 만료됐다는 에러이다.
다시 개인키와 자체 서명 인증서를 생성하여 배포한다.
0. 개념정리
진행하기 전에 개념을 정리한다.
SSL/TLS : 인터넷에서 클라이언트와 서버간에 안전한 데이터 소통을 위한 암호화된 프로토콜
-> 보통 https 인 사이트가 ssl/tls 적용된 사이트
tls는 ssl의 더 보안이 강화된 버전. 보통 tls가 사용된다.
이렇게 ssl/tls가 적용된 사이트에 접속하려면 인증을 위한 공개키가 필요하다.
그러기 위해서 .jks 파일과 .cert파일이 필요하다.
.jks파일은 Java KeyStore로서 개인키와 개인키와 상응되는 공개키를 이 키스토어에 저장한다.
자바 기반 애플리케이션에 ssl/tls을 설정할 때 사용된다.
.cer파일은 Certificate파일로서 .jks 파일의 개인키로부터 공개키를 추출한 파일이다.
따라서 추후에 클라이언트가 서버에 접근할 때 이 .cer파일로서 접근을 하게 된다.
1. SSL/TLS 키 생성
트리노 코디네이터가 있는 노드에서 진행
[root@mycluster001 ~]# cd /usr/mycluster/trino/ca_key/ #ssl/tls에서 사용될 .jks 파일 생성 [root@mycluster001 ca_key]# keytool -genkeypair -alias trino_cert_250213 -keyalg RSA \ -keystore /usr/mycluster/trino/ca_key/trino_keystore_250213.jks \ -dname "CN=trino_cert_250213" \ -ext "SAN=DNS:mycluster001.fqdn.io,IP:10.10.10.10" \ -keypass mypassword \ -storepass mypassword \ -validity 36500 [root@mycluster001 ca_key]# ll 합계 20 -rw-r--r-- 1 root root 2142 2월 13 13:24 trino_keystore_250213.jks #.jks파일의 개인키로부터 이와 상응하는 공개키 추출 [root@mycluster001 ca_key]# keytool -exportcert -keystore /usr/mycluster/trino/ca_key/trino_keystore_250213.jks \ -alias trino_cert_250213 \ -file /usr/mycluster/trino/ca_key/trino_ca_250213.cer \ -storepass mypassword [root@mycluster001 ca_key]# ll 합계 24 -rw-r--r-- 1 root root 779 2월 13 13:26 trino_ca_250213.cer -rw-r--r-- 1 root root 2142 2월 13 13:24 trino_keystore_250213.jks #파일 소유주 변경 [root@mycluster001 ca_key]# chown trino:hadoop trino_ca_250213.cer trino_keystore_250213.jks #trino shell을 사용하여 https로 접속하고자 하는 노드에 적용을 위해 배포한다. [root@mycluster001 ca_key]# scp -r trino_ca_250213.cer root@mycluster002:/root/ #해당 노드로 접속해서 인증서 등록 [root@mycluster002 ~]# keytool -importcert -alias trino_trust_250213 -keystore /etc/alternatives/jre/lib/security/cacerts \ -file /root/trino_ca_250213.cer \ -storepass changeit -trustcacerts #keystore에 certificate 등록 확인 / 'cacerts' keystore의 비번은 'changeit' 이다. [root@mycluster002 ~]# keytool -list -v -alias trino_trust_250213 -keystore /etc/alternatives/jre/lib/security/cacerts |
2. Password Authentication설정
트리노 코디네이터 노드에서 작업
[root@mycluster001 ca_key]# cd /usr/mycluster/trino/etc [root@mycluster001 etc]# ll 합계 24 drwxr-xr-x. 2 trino hadoop 29 3월 12 2024 catalog -rw-r--r--. 1 trino hadoop 1256 3월 15 2024 config.properties -rw-r--r--. 1 trino hadoop 359 3월 12 2024 jvm.config -rw-r--r--. 1 trino hadoop 21 3월 12 2024 log.properties -rw-r--r--. 1 trino hadoop 113 3월 12 2024 node.properties -rw-r--r--. 1 trino hadoop 95 3월 14 2024 password-authenticator.properties -rw-r--r--. 1 trino hadoop 271 3월 15 2024 password.db #아래 내용 확인 [root@mycluster001 etc]# vim password-authenticator.properties password-authenticator.name=file file.password-file=/usr/mycluster/trino/etc/password.db [root@mycluster001 etc]# cp /usr/mycluster/trino/ca_key/trino_keystore_250213.jks /usr/mycluster/trino/etc/ [root@mycluster001 etc]# ll /usr/mycluster/trino/etc/ 합계 28 drwxr-xr-x. 2 trino hadoop 29 3월 12 2024 catalog -rw-r--r--. 1 trino hadoop 1256 3월 15 2024 config.properties -rw-r--r--. 1 trino hadoop 359 3월 12 2024 jvm.config -rw-r--r--. 1 trino hadoop 21 3월 12 2024 log.properties -rw-r--r--. 1 trino hadoop 113 3월 12 2024 node.properties -rw-r--r--. 1 trino hadoop 95 3월 14 2024 password-authenticator.properties -rw-r--r--. 1 trino hadoop 271 3월 15 2024 password.db -rw-r--r-- 1 trino hadoop 2142 2월 13 14:16 trino_keystore_250213.jks #서버에서 암호화된 키 생성 - 추후 사용을 위해 복사 [root@mycluster001 etc]# openssl rand 512 | base64 abcdefghijk..... 이제 암바리에서 트리노 config들을 수정해준다. Advanced trino-ambari-config trino.https.enabled : check Advanced trino-config-properties → content http-server.https.keystore.path={{trino_config_dir}}/trino_keystore_250213.jks ## 해당 key가 /usr/mycluster/trino/etc 밑에 있게 옮겨 줄 것, trino_keystore_250213.jks 인지 이름 확인! http-server.https.keystore.key={PASSWD} discovery.uri=https://[coordinator의 IP]:9998 internal-communication.shared-secret=abcdefghijk..... |
3. Hue에 SSL 적용된 Trino 연동
이제 휴와 트리노를 연동한다.
#Trino와 Hue연동에 필요한 Hue 파이썬 패키지가 있는지 확인한다. #SQLAlchemy는 1.3버전 이상이면 된다. [root@mycluster001 ~]# /usr/mycluster/hue/build/env/bin/pip list | grep SQL SQLAlchemy 1.3.8 [root@mycluster001 ~]# /usr/mycluster/hue/build/env/bin/pip install 'pyhive[trino]==0.6.5' #기존 생성한 jks 파일을 .pem 파일로 변환하기 위해 pkcs12 파일 선변환 [root@mycluster001 ~]# keytool -importkeystore -srckeystore /usr/mycluster/trino/ca_key/trino_keystore_250213.jks -destkeystore /usr/mycluster/trino/ca_key/trans_250213.p12 -deststoretype PKCS12 키 저장소 /usr/mycluster/trino/ca_key/trino_keystore_250213.jks을(를) /usr/mycluster/trino/ca_key/trans_250213.p12(으)로 임포트하는 중... 대상 키 저장소 비밀번호 입력: 새 비밀번호 다시 입력: 소스 키 저장소 비밀번호 입력: trino_cert_250213 별칭에 대한 항목이 성공적으로 임포트되었습니다. 임포트 명령 완료: 성공적으로 임포트된 항목은 1개, 실패하거나 취소된 항목은 0개입니다. #pkcs12 파일 이용해서 .pem 파일 변환 필요 (패스워드는 .jks 의 패스워드 동일하게 입력) [root@mycluster001 ~]# openssl pkcs12 -in /usr/mycluster/trino/ca_key/trans_250213.p12 -out /usr/mycluster/trino/ca_key/trino_ca_250213.pem -clcerts Enter Import Password: MAC verified OK Enter PEM pass phrase: Verifying - Enter PEM pass phrase: [root@mycluster001 ~]# ll /usr/mycluster/trino/ca_key 합계 32 -rw-r--r-- 1 root root 2517 2월 13 15:56 trans_250213.p12 -rw-r--r-- 1 trino hadoop 779 2월 13 13:26 trino_ca_250213.cer -rw-r--r-- 1 root root 3280 2월 13 15:58 trino_ca_250213.pem -rw-r--r-- 1 trino hadoop 2142 2월 13 13:24 trino_keystore_250213.jks #권한 설정 [root@mycluster001 ~]# chown trino:hadoop /usr/mycluster/trino/ca_key/* |
이제 hue.ini파일에서 presto부분을 아래와 같이 수정해준다.
[[[presto]]] name=Trino interface=sqlalchemy options='{"url": "trino+pyhive://mycluster.fqdn.io:9998/hive/default", "has_impersonation": true, "connect_args": "{\"username\":\"trino\", \"password\":\"mypassword\",\"protocol\": \"https\", \"requests_kwargs\": {\"verify\": \"/usr/mycluster/trino/ca_key/trino_ca_250213.pem\"}}"}' |
Hue 재기동한다.
그럼 맨 처음 에러가 사라진 것을 확인할 수 있다.
728x90
반응형
Comments