성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] Roll A Lisp In C - Reading ; https...
[정성태] Java - How to use the Foreign Funct...
[정성태] 제가 큰 실수를 했군요. ^^; Delegate를 통한 Bein...
[정성태] Working with Rust Libraries from C#...
[정성태] Detecting blocking calls using asyn...
[정성태] 아쉽게도, 커뮤니티는 아니고 개인 블로그입니다. ^^
[정성태] 질문이 잘 이해가 안 됩니다. 우선, 해당 소스코드에서 ILis...
[양승조
] var대신 dinamic으로 선언해서 해결은 했습니다. 맞는 해...
[양승조
] 또 막혔습니다. ㅠㅠ var list = props[i].Ge...
[양승조
] 아. 감사합니다. 어제는 안됐던것 같은데....정신을 차려야겠네...
글쓰기
제목
이름
암호
전자우편
HTML
홈페이지
유형
제니퍼 .NET
닷넷
COM 개체 관련
스크립트
VC++
VS.NET IDE
Windows
Team Foundation Server
디버깅 기술
오류 유형
개발 환경 구성
웹
기타
Linux
Java
DDK
Math
Phone
Graphics
사물인터넷
부모글 보이기/감추기
내용
<div style='display: inline'> <h1 style='font-family: Malgun Gothic, Consolas; font-size: 20pt; color: #006699; text-align: center; font-weight: bold'>리눅스/WSL에서 CA 인증서를 저장하는 방법</h1> <p> 지난 글에서 openssl로 생성한 인증서를 적용한 웹 사이트를,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > OpenSSL로 생성한 사용자 인증서를 ASP.NET Core 웹 사이트에 적용하는 방법 ; <a target='tab' href='https://www.sysnet.pe.kr/2/0/13443'>https://www.sysnet.pe.kr/2/0/13443</a> </pre> <br /> (간단하게는 WSL 환경의) Ubuntu에서 접근해 보면,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > $ <span style='color: blue; font-weight: bold'>cat /etc/resolv.conf</span> # This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf: # [network] # generateResolvConf = false <span style='color: blue; font-weight: bold'>nameserver 172.18.208.1</span> $ <span style='color: blue; font-weight: bold'>curl https://172.18.208.1:7252</span> curl: (60) SSL certificate problem: unable to get local issuer certificate More details here: https://curl.haxx.se/docs/sslcerts.html curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it. To learn more about this situation and how to fix it, please visit the web page mentioned above. </pre> <br /> 당연히, CA 인증서가 해당 Ubuntu 환경에는 없으므로 인증서 검증에 실패합니다. (인증서 검증 단계를 생략하도록 <a target='tab' href='https://www.sysnet.pe.kr/2/0/13442#insecure'>--insecure 옵션</a>을 추가하면 됩니다.)<br /> <br /> 따라서, Ubuntu 환경에도 test_ca.crt 인증서를 설치해야 하는데요,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Install CA certificates on Linux systems ; <a target='tab' href='https://www.hs-schmalkalden.de/en/university/faculties/faculty-of-electrical-engineering/studium/use-of-it/install-ca-certificates-on-linux-systems'>https://www.hs-schmalkalden.de/en/university/faculties/faculty-of-electrical-engineering/studium/use-of-it/install-ca-certificates-on-linux-systems</a> </pre> <br /> 위의 글에서 소개하는 방법에 따라 (제 경우에는 Ubuntu이므로) ca-certificates 디렉터리에 복사해 둔 후,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > $ sudo cp /mnt/c/temp/cert/test_ca.crt /usr/local/share/ca-certificates </pre> <br /> update-ca-certificates 명령어를 실행하면,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > $ sudo update-ca-certificates </pre> <br /> /usr/local/share/ca-certificates 디렉터리에 복사했던 인증서가 /etc/ssl/certs/ca-certificates.crt 파일에 추가됩니다. 해당 파일에는 BEGIN/END CERTIFICATE 문자열이 잔뜩 들어가 있는데, 이것을 쉽게 해석하기 위해서는 다음의 명령어를 사용할 수 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > // List all available ssl ca certificates // https://unix.stackexchange.com/questions/97244/list-all-available-ssl-ca-certificates $ <span style='color: blue; font-weight: bold'>awk -v cmd='openssl x509 -noout -subject' '/BEGIN/{close(cmd)};{print | cmd}' < /etc/ssl/certs/ca-certificates.crt</span> ...[생략]... subject=CN = testca </pre> <br /> 그렇다면, 당연히 이제부터는 curl 명령어가 정상적으로 동작하게 됩니다. 만약 그래도 문제가 있다면, <a target='tab' href='https://www.sysnet.pe.kr/2/0/11462#13373'>SSL과 관련한 상세 정보를 얻기 위해 openssl을 이용</a>하는 것도 좋습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > $ openssl s_client -showcerts -connect 172.18.208.1:7252 </pre> <br /> <hr style='width: 50%' /><br /> <br /> 지난 글에서 만든 인증서는 "DNS:test.testhvpc.com" 항목도 포함하고 있는데요, 당연히 리눅스에도 (윈도우의 HOSTS 파일에 해당하는) "/etc/hosts" 파일을 편집해 해당 DNS를 설정하면,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > $ cat /etc/hosts # This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf: # [network] # generateHosts = false 172.18.208.1 test.testhvpc.com ...[생략]... </pre> <br /> 이렇게 테스트할 수 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > $ curl https://test.testhvpc.com:7252 </pre> <br /> 참고로, WSL 환경의 /etc/hosts 파일은 해당 우분투 인스턴스가 재시작하면 윈도우의 HOSTS 파일로부터 재작성되므로, 지속성을 위해서라면 윈도우의 HOSTS 파일에 저 항목을 넣어두어야 합니다.<br /> <br /> 그런데, 재미있는 현상이 하나 있습니다. <a target='tab' href='https://www.sysnet.pe.kr/2/0/13480'>WSL 2 환경이라면 Google Chrome 브라우저를 설치해 실행하는 것도 가능</a>한데요,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > How to Install Firefox and Google Chrome in WSL2 on Windows 10 ; <a target='tab' href='https://www.freshtechtips.com/2022/12/install-firefox-google-chrome-in-wsl.html'>https://www.freshtechtips.com/2022/12/install-firefox-google-chrome-in-wsl.html</a> </pre> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > $ sudo apt update && sudo apt upgrade -y $ sudo wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb $ sudo dpkg -i google-chrome-stable_current_amd64.deb $ sudo apt install --fix-broken -y $ sudo dpkg -i google-chrome-stable_current_amd64.deb $ google-chrome </pre> <br /> 그렇게 실행한 브라우저에서 "https://test.testhvpc.com:7252" 주소를 방문하면 "<a target='tab' href='https://www.sysnet.pe.kr/2/0/13236#ca_error'>NET::ERR_CERT_AUTHORITY_INVALID</a>" 오류가 발생합니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Your connection is not private Attackers might be trying to steal your information from test.testhvpc.com (for example, passwords, messages, or credit cards). Learn more NET::ERR_CERT_AUTHORITY_INVALID This server could not prove that it is test.testhvpc.com; its security certificate is not trusted by your computer's operating system. This may be caused by a misconfiguration or an attacker intercepting your connection. Proceed to test.testhvpc.com (unsafe) </pre> <br /> 왜냐하면, 크롬의 경우에는 인증서 저장소를 별도 관리하기 때문인데,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > SSL certificate in system store not trusted by Chrome ; <a target='tab' href='https://serverfault.com/questions/946756/ssl-certificate-in-system-store-not-trusted-by-chrome'>https://serverfault.com/questions/946756/ssl-certificate-in-system-store-not-trusted-by-chrome</a> </pre> <br /> 따라서 "settings -> privacy and security -> security -> manage certificates" 설정에 들어가 "Authorities" 탭에서 CA 인증서를 "Trust this certificate for identifying websites" 옵션으로 추가하면 됩니다.<br /> <br /> 만약 "Authorities"가 아닌 다른 탭, 예를 들어 "Your certificates" 탭에서 추가하려고 시도하면 이런 오류가 발생합니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Certificate Import Error The Private Key for this Client Certificate is missing or invalid </pre> </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
1056
(왼쪽의 숫자를 입력해야 합니다.)