728x90

SSL 인증서 중 Comodo  인증서가 sectigo 인증서로 변경되면서 일부 리눅스 시스템 내 Root/chain 인증서가 반영이 안되 어  있어 JAVA SSL HandshakeException 및 Curl  오류가 발생합니다.

 

 

"Sectigo(COMODO)의 “AddTrust External Root CA” 만료 이후 HTTPS 접속 오류 현상 관련 안내드립니다." 에서 확인이 가능합니다.

www.certkorea.co.kr/bbs/board.php?bo_table=31&wr_id=30

 

Sectigo(COMODO)의 “AddTrust External Root CA” 만료 이후 HTTPS 접속 오류 현상 관련 안내드립니다. > 공지�

> 고객지원/이벤트 > 공지사항 공지사항

www.certkorea.co.kr

 

오류 2 . javax.net.ssl.SSLHandshakeException

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

 

 

이와 같은 경우에는 keytool을 이용해서 인증서를 추가해줘야 합니다.

 

Chain_RootCA_Bundle.zip
0.05MB

 

# keytool 로 인증서 추가하기

 

# cd ${JAVA_HOME}/jre/lib/security/cacerts
# keytool -list -keystore ${JAVA_HOME}/jre/lib/security/cacerts
키 저장소 비밀번호 입력:  changeit

 

# keytool -import -keystore ${JAVA_HOME}/jre/lib/security/cacerts -file "CA Root 인증서"  -alias "인증서별칭"

예) 

# cd ${JAVA_HOME}/jre/lib/security/cacerts

# keytool -list -keystore ${JAVA_HOME}/jre/lib/security/cacerts

키 저장소 비밀번호 입력:  changeit
키 저장소 비밀번호 입력:  
키 저장소 유형: JKS
키 저장소 제공자: SUN
키 저장소에 104개의 항목이 포함되어 있습니다.

verisignclass2g2ca [jdk], 2016. 8. 26, trustedCertEntry, 
인증서 지문(SHA1): B3:EA:C4:47:76:C9:C8:1C:EA:F2:9D:95:B6:CC:A0:08:1B:67:EC:9D
digicertassuredidg3 [jdk], 2016. 8. 26, trustedCertEntry, 
인증서 지문(SHA1): F5:17:A2:4F:9A:48:C6:C9:F8:A2:00:26:9F:DC:0F:48:2C:AB:30:89
verisignuniversalrootca [jdk], 2016. 8. 26, trustedCertEntry, 
인증서 지문(SHA1): 36:79:CA:35:66:87:72:30:4D:30:A5:FB:87:3B:0F:A7:7B:B7:0D:54
digicerttrustedrootg4 [jdk], 2016. 8. 26, trustedCertEntry, 
인증서 지문(SHA1): DD:FB:16:CD:49:31:C9:73:A2:03:7D:3F:C8:3A:4D:7D:77:5D:05:E4
verisignclass1g3ca [jdk], 2016. 8. 26, trustedCertEntry, 
인증서 지문(SHA1): 20:42:85:DC:F7:EB:76:41:95:57:8E:13:6B:D4:B7:D1:E9:8E:46:A5
identrustpublicca [jdk], 2016. 8. 26, trustedCertEntry, 

# keytool -import -keystore ${JAVA_HOME}/jre/lib/security/cacerts -file "Chain_RootCA_Bundle.crt" -alias "sectigorsatrust"

........
#5: ObjectId: 2.5.29.32 Criticality=false
CertificatePolicies [
  [CertificatePolicyId: [2.5.29.32.0]
[]  ]
  [CertificatePolicyId: [2.23.140.1.2.1]
[]  ]
]

#6: ObjectId: 2.5.29.37 Criticality=false
ExtendedKeyUsages [
  serverAuth
  clientAuth
]

#7: ObjectId: 2.5.29.15 Criticality=true
KeyUsage [
  DigitalSignature
  Key_CertSign
  Crl_Sign
]

#8: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: 8D 8C 5E C4 54 AD 8A E1   77 E9 9B F9 9B 05 E1 B8  ..^.T...w.......
0010: 01 8D 61 E1                                        ..a.
]
]

이 인증서를 신뢰합니까? [아니오]:  y
인증서가 키 저장소에 추가되었습니다.

 

# 추가한 인증서를 삭제하고자 할 경우 

# keytool -delete -alias "알리아스인증서명칭" -keystore "cacerts가 있는 경로"

예) keytool -delete -alias "usertrustrsacaroot" -keystore ${JAVA_HOME}/jre/lib/security/cacerts 

 


 

참고 URL

blog.naver.com/kgj1/220584997842
www.securesign.kr/guides/kb/47

m.blog.naver.com/PostView.nhn?blogId=toy_ssl&logNo=110168927395&proxyReferer=https:%2F%2Fwww.google.com%2F

 

 

728x90

SSL 인증서 중 Comodo  인증서가 sectigo 인증서로 변경되면서 일부 리눅스 시스템 내 Root/chain 인증서가 반영이 안되 어  있어 JAVA SSL HandshakeException 및 Curl  오류가 발생합니다.

 

"Sectigo(COMODO)의 “AddTrust External Root CA” 만료 이후 HTTPS 접속 오류 현상 관련 안내드립니다." 에서 확인이 가능합니다.

www.certkorea.co.kr/bbs/board.php?bo_table=31&wr_id=30

 

Sectigo(COMODO)의 “AddTrust External Root CA” 만료 이후 HTTPS 접속 오류 현상 관련 안내드립니다. > 공지�

> 고객지원/이벤트 > 공지사항 공지사항

www.certkorea.co.kr

 

오류 1 . curl https://www.OOOOO.co.kr cli 명령시 에러 발생

인증서가 교체 된 이후에 https://www.OOOO.co.kr로 접속할 경우 원할하지 않은 부분이 발생할 수 있습니다.

예를 들어 아래와 같은 문제가 발생할 수 있습니다.

# curl https://www.OOOOO.co.kr

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.

 

 

 

위와 같이 에러가 뜬다면 

 

서버의 인증서 Root CA 를 추가해 줘야 합니다.

 

0.  먼저 CA 파일의 경로를 찾습니다.

아래와 같이 curl -v https://www.OOOOO.co.kr로 하면 CAfile 파일 경로 위치를 확인할 수 있습니다.


1. 먼저 서버에 Chain_RootCA_Bundle.zip 압축파일을 풀어서 ftp로 업로드 합니다.
2. 업로드된 파일로 콘솔로 들어가야 함.

# cd ./Chain_RootCA_Bundle 
# ll /etc/pki/tls/certs/ca-bundle.crt
# cp /etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/ca-bundle.crt.20201006
# printf "\n### Sectigo_RSA_AddTrust_codesign Add $(date '+%Y.%m.%d') \n " >> /etc/pki/tls/certs/ca-bundle.crt
# cat Chain_RootCA_Bundle.crt | sed -e "s/\\r//g" >>  /etc/pki/tls/certs/ca-bundle.crt

Chain_RootCA_Bundle.zip
0.05MB

 

첨부파일을 보시고서 자신에 맞는 폴더에서 확인 작업하시면 됩니다.

[15:35:43 root@home:~#] ll /etc/pki/tls/certs/ca-bundle.crt
lrwxrwxrwx 1 root root 49  5월 20  2016 /etc/pki/tls/certs/ca-bundle.crt -> /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem

[15:35:52 root@home:~#] cp /etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/ca-bundle.crt.20201006


[15:36:28 root@home:/home#] cd Chain_RootCA_Bundle/
[15:36:32 root@home:/home/Chain_RootCA_Bundle#] ls
ChainCA1.crt  ChainCA2.crt  Chain_RootCA_Bundle.crt  RootCA.crt  add_sectigo_cert.sh

[15:36:33 root@home:/home/Chain_RootCA_Bundle#] printf "\n### Sectigo_RSA_AddTrust_codesign Add $(date '+%Y.%m.%d') \n " >> /etc/pki/tls/certs/ca-bundle.crt
[15:36:50 root@home:/home/Chain_RootCA_Bundle#] cat Chain_RootCA_Bundle.crt | sed -e "s/\\r//g" >>  /etc/pki/tls/certs/ca-bundle.crt
[15:36:53 root@home:/home/Chain_RootCA_Bundle#] curl https://www.OOOOOO.co.kr
....

 

 

 


참고 URL

www.securesign.kr/guides/kb/47

louky0714.tistory.com/entry/Linux-sectigo-rootchain-%EC%9D%B8%EC%A6%9D%EC%84%9C-%EC%B6%94%EA%B0%80

 

728x90

참고URL

리눅스 메모리 사용률 확인

zetawiki.com/wiki/%EB%A6%AC%EB%88%85%EC%8A%A4_%EB%A9%94%EB%AA%A8%EB%A6%AC_%EC%82%AC%EC%9A%A9%EB%A5%A0_%ED%99%95%EC%9D%B8

 

Nginx, PHP-FPM에서 child process 개수 결정하기

yumere.tistory.com/81


# 프로세스중 메모리를 많이 사용하는 프로세스 리스트를 뽑아낸다.

# ps -ef --sort -rss

# ps -ef --sort -rss

UID        PID  PPID  C STIME TTY          TIME CMD
root     14801     1  0 Aug24 ?        00:00:36 /usr/local/apache/bin/httpd -k start
root     30654     1  0 Aug26 ?        00:03:02 java -jar ../server/tubro-site-main-1.0.0-SNAPSHOT.jar --server.port=8182
root     30607     1  0 Aug26 ?        00:02:43 java -jar ../server/test-swagger-1.0.0-SNAPSHOT.jar --server.port=8181
nobody     396 14801  0 Aug26 ?        00:00:44 /usr/local/apache/bin/httpd -k start
nobody     395 14801  0 Aug26 ?        00:00:50 /usr/local/apache/bin/httpd -k start
nobody    3556 14801  0 Aug26 ?        00:00:45 /usr/local/apache/bin/httpd -k start
nobody   32734 14801  0 Aug26 ?        00:00:50 /usr/local/apache/bin/httpd -k start
mysql    30313 29796  0  2019 ?        02:31:44 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/home/mysql/data --plugin-dir=/usr/local/mysql/lib/plu
root     11757     1  0  2019 ?        00:29:47 /sbin/rsyslogd -i /var/run/syslogd.pid -c 5
root      3203 15675  0 18:15 ?        00:00:00 sshd: hanchiro [priv]
root      3233  3206  0 18:15 pts/0    00:00:00 su -
root      3235     1  0 18:15 ?        00:00:00 /usr/libexec/fprintd

 

 

# php-fpm 프로세스중에서 메모리를 많이 사용하는 리스트를 뽑아낸다.

# ps -ylC php-fpm --sort:rss

 

#java 프로세스의 메모리 사용량을 볼 수 있다.
ps -ylC java --sort:rss

# ps -ylC java --sort:rss
S   UID   PID  PPID  C PRI  NI   RSS    SZ WCHAN  TTY          TIME CMD
S     0 30607     1  0  80   0 510144 1473060 futex_ ?     00:02:43 java
S     0 30654     1  0  80   0 859748 1542193 futex_ ?     00:03:02 java

RSS를 보면 평균 사용 메모리를 KB로 표시해준다.
위 명령어 외에 좀 더 확실해게 보려면 아래 명령어를 입력해보면 된다.

 

PHP-FPM으로 사용가능한 memory / Processor 당 메모리 사용량으로 나누면 pm.max_children 개수를 정할 수 있다.
ps --no-headers -o "rss,cmd" -C java | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"Mb") }'

# ps --no-headers -o "rss,cmd" -C java | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"Mb") }'
668Mb


<< bash 스크립트 >>

#!/bin/bash

TOTAL=`free | grep ^Mem | awk '{print $2}'`
USED1=`free | grep ^Mem | awk '{print $3}'`
USED2=`free | grep ^-/+ | awk '{print $3}'`

NOMINAL=$((100*USED1/TOTAL))
ACTUAL=$((100*USED2/TOTAL))

MEMTOTLA=`cat /proc/meminfo | grep MemTotal`

# NOMINAL=`echo "100*$USED1/$TOTAL" | bc -l`
# ACTUAL=`echo "100*$USED2/$TOTAL" | bc -l`

echo '--------------------------------------------------'
echo ${MEMTOTLA}

echo NOMINAL=${NOMINAL:0:5}% ACTUAL=${ACTUAL:0:5}%
echo '--------------------------------------------------'
echo 'NOMINAL : 명목, ACTUAL : 실질, rss : 물리메모리'
echo '--------------------------------------------------'
echo '물리메모리 사용량 TOP 10'
ps -eo user,pid,ppid,rss,size,vsize,pmem,pcpu,time,comm --sort -rss | head -n 11
echo '--------------------------------------------------'
echo 'SWAP메모리 사용량 TOP 10'
ps -eo user,pid,ppid,rss,size,vsize,pmem,pcpu,time,comm --sort -size | head -n 11

[root@KSERVER145-25 ~]# ./memory_check.sh 
--------------------------------------------------
MemTotal: 7894176 kB
NOMINAL=98% ACTUAL=37%
--------------------------------------------------
NOMINAL : 명목, ACTUAL : 실질, rss : 물리메모리
--------------------------------------------------
물리메모리 사용량 TOP 10
USER       PID  PPID   RSS    SZ    VSZ %MEM %CPU     TIME COMMAND
root     14801     1 4342480 6220 4624664 55.0 0.0 00:00:36 httpd
root     30654     1 859844 6019212 6168772 10.8 0.0 00:03:02 java
root     30607     1 510144 5742716 5892240  6.4 0.0 00:02:43 java
nobody     396 14801 291316 5440208 10060724  3.6 0.0 00:00:44 httpd
nobody     395 14801 280584 5438416 10058960  3.5 0.0 00:00:51 httpd
nobody    3556 14801 270376 5438416 10058932  3.4 0.0 00:00:45 httpd
nobody   32734 14801 257716 5438416 10058960  3.2 0.0 00:00:50 httpd
mysql    30313 29796 163408 4145948 4183520  2.0 0.0 02:31:44 mysqld
root     11757     1  5088 228600 256192  0.0 0.0 00:29:47 rsyslogd
root      3203 15675  4120   616  73456  0.0  0.0 00:00:00 sshd
--------------------------------------------------
SWAP메모리 사용량 TOP 10
USER       PID  PPID   RSS    SZ    VSZ %MEM %CPU     TIME COMMAND
root     30654     1 859844 6019212 6168772 10.8 0.0 00:03:02 java
root     30607     1 510144 5742716 5892240  6.4 0.0 00:02:43 java
nobody     396 14801 291316 5440208 10060724  3.6 0.0 00:00:44 httpd
nobody     395 14801 280584 5438416 10058960  3.5 0.0 00:00:51 httpd
nobody    3556 14801 270376 5438416 10058932  3.4 0.0 00:00:45 httpd
nobody   32734 14801 257716 5438416 10058960  3.2 0.0 00:00:50 httpd
mysql    30313 29796 163408 4145948 4183520  2.0 0.0 02:31:44 mysqld
root      2399     1   812 4078160 4116684  0.0 0.0 00:00:01 console-kit-dae
root     11757     1  5088 228600 256192  0.0 0.0 00:29:47 rsyslogd
68        1904     1  1076 11216  38212  0.0  0.0 00:09:54 hald

memory_check.sh.zip
0.00MB

 

728x90

mysql 8.x user 생성 및 변경, 삭제 처리 하기

 

> mysql 에 접속하시고 user 테이블로 이동 하셔서 

insert into user (Host,User,authentication_string,ssl_cipher,x509_issuer,x509_subject) values ('localhost','유저명', '', '','','');

 

insert into user (Host,User,authentication_string,ssl_cipher,x509_issuer,x509_subject) values ('localhost','유저명', '', '','','');

 

위와 같이 MySQL5.X버전의 경우와 같은 SQL문으로 user를 생성하지마세요.

 

유저가 생성되지 않습니다.

 

 

그럼 mysql에 user를 만들어 비밀번호를 반영하여 접속하는 방법을 설명하겠습니다.

먼저 MySQL에 root로 접속하신 후 mysql DB 이동해 주세요. 


0. MySQL에 root로 접속하여 mysql DB 로 이동해 주세요.

use mysql;

 

1. 사용자 정보 조회를 먼저 조회하세요.

SELECT user,authentication_string,plugin,host FROM mysql.user; 

SELECT user,authentication_string,plugin,host FROM mysql.user; 

그러면 위와 같이 뜨게 됩니다.

단, plugin 부분이 "caching_sha2_password" 로 되어서 암호화된 비밀번호의 형태가 다를 수 있습니다.

위의 경우에는 제가 "mysql_native_password" 로 변경한 것이기 때문입니다.

 

여전히 MySQL 클라이언트에서는 "caching_sha2_password" 플러그인이 반영되지 않아서 connect 가 안되기에 기존에 사용하던 "mysql_native_password" 로 변경하였기 때문입니다.

이 부분에 대해서는 아래에 변경하는 방법을 적어놨습니다.

 

2. 사용자 생성를 생성합니다.
create user '유저명'@'localhost' identified by '비밀번호'; 

create user '유저명'@'localhost' identified by '비밀번호'; 

 

3. 생성된 사용자를 확인합니다.
SELECT user,authentication_string,plugin,host FROM mysql.user; 

SELECT user,authentication_string,plugin,host FROM mysql.user; 

 

4. 생성된 사용자의 권한을 적용시켜 줍니다.
GRANT ALL PRIVILEGES ON *.* TO '유저명'@'localhost'; 
GRANT GRANT OPTION ON *.* TO '유저명'@'localhost'; 

GRANT ALL PRIVILEGES ON *.* TO '유저명'@'localhost'; 
GRANT GRANT OPTION ON *.* TO '유저명'@'localhost'; 

 

5. MySQL에 실시간 반영시켜 줍니다.
flush privileges;

flush privileges;

 

 

참고. MySQL에서 caching_sha2_password 을 mysql_native_password으로 플러그인을 변경하기

ALTER user '유저명'@'localhost' IDENTIFIED WITH mysql_native_password by '비밀번호';

ALTER user '유저명'@'localhost' IDENTIFIED WITH mysql_native_password by '비밀번호';

여전히 MySQL 클라이언트에서는 "caching_sha2_password" 플러그인이 반영되지 않아서 connect 가 안되기에 기존에 사용하던 "mysql_native_password" 로 변경하였기 때문입니다.

 


6. 사용자를 삭제할 수 있습니다.
drop user 유저명@localhost;

drop user 유저명@localhost;
flush privileges;

삭제하고 나면 꼭 "flush privileges;" 를 해주세요. MySQL에 제대로 반영을 시켜줘야 합니다.

그렇지 않으면 메모리상에 USER 정보가 남아 있어 동일한 "유저명" 으로 재생성할 수 없습니다.

예를 들어 아래와 같이 SQL문중 delete 문으로 유저를 삭제하고서 다시 동일한 유저를 생성하게 되면 에러가 뜨게 됩니다.

ERROR 1396 (HY000): Operation  관련 에러가 뜨게 됩니다.

mysql> delete from user where User='유저명';

Query OK, 1 row affected (0.00 sec)



mysql> create user '유저명'@'localhost' identified by '비밀번호'; 

ERROR 1396 (HY000): Operation CREATE USER failed for '유저명'@'localhost'

mysql> delete from user where User='유저명';

Query OK, 1 row affected (0.00 sec)

 

mysql> create user '유저명'@'localhost' identified by '비밀번호'; 

ERROR 1396 (HY000): Operation CREATE USER failed for '유저명'@'localhost'

 

아래는 실제 에러가 떠서 "Drop User " 명령문으로 삭제하고 CREATE USER 명령문으로 재 생성한 화면입니다.

+ Recent posts