developer tip

localhost에 대한 자체 서명 된 인증서를 만들려면 어떻게해야합니까?

optionbox 2020. 8. 9. 10:20
반응형

localhost에 대한 자체 서명 된 인증서를 만들려면 어떻게해야합니까?


localhost에서 https / SSL을 어떻게 사용합니까?에 자세히 설명 된 단계를 수행했습니다 . 하지만 이것은 내 컴퓨터 이름에 대해 자체 서명 된 인증서를 설정하고 https : // localhost 를 통해 검색 할 때 IE 경고를받습니다.

이 경고를 피하기 위해 "localhost"에 대한 자체 서명 된 인증서를 만드는 방법이 있습니까?


이 게시물은 Windows 용으로 태그가 지정되어 있지만 다른 곳에서는 답변을 보지 못한 OS X 관련 질문입니다. OS X 에서 localhost에 대한 자체 서명 된 인증서를 만드는 단계는 다음과 같습니다 .

# Use 'localhost' for the 'Common name'
openssl req -x509 -sha256 -nodes -newkey rsa:2048 -days 365 -keyout localhost.key -out localhost.crt

# Add the cert to your keychain
open localhost.crt

에서 Keychain Access,이 새로운 로컬 호스트 인증서를 두 번 클릭합니다. "신뢰"옆의 화살표를 확장하고 "항상 신뢰"를 선택합니다. 이제 Chrome과 Safari가이 인증서를 신뢰해야합니다. 예를 들어,이 인증서를 node.js와 함께 사용하려면 다음을 수행하십시오.

var options = {
    key: fs.readFileSync('/path/to/localhost.key').toString(),
    cert: fs.readFileSync('/path/to/localhost.crt').toString(),
    ciphers: 'ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES256-SHA384',
    honorCipherOrder: true,
    secureProtocol: 'TLSv1_2_method'
};

var server = require('https').createServer(options, app);

이 문제에 대해 많은 시간을 보낸 후 IIS를 사용하여 자체 서명 된 인증서를 만드는 제안을 따를 때마다 발견 한 발급 대상 및 발급자가 올바르지 않음을 발견했습니다. SelfSSL.exe가이 문제를 해결하는 열쇠였습니다. 다음 웹 사이트는 자체 서명 된 인증서를 만드는 단계별 접근 방식을 제공했을뿐만 아니라 발급 대상 및 발급자 문제도 해결했습니다. 다음 은 자체 서명 된 인증서를 만들기 위해 찾은 최상의 솔루션입니다. 비디오 형식으로 동일한 자습서를 보려면 여기를 클릭하십시오 .

SelfSSL의 샘플 사용은 다음과 같습니다.

SelfSSL /N:CN=YourWebsite.com / V : 1000 / S : 2

SelfSSL /? 설명과 함께 매개 변수 목록을 제공합니다.


PowerShell을 사용하여 new-selfsignedcertificate cmdlet으로 자체 서명 된 인증서를 생성 할 수 있습니다.

New-SelfSignedCertificate -DnsName "localhost" -CertStoreLocation "cert:\LocalMachine\My"

참고 : makecert.exe는 더 이상 사용되지 않습니다.

Cmdlet 참조 : https://technet.microsoft.com/itpro/powershell/windows/pkiclient/new-selfsignedcertificate


이 질문에 태그가 붙어 IIS있고 신뢰할 수있는 인증서를 얻는 방법에 대한 좋은 답을 찾을 수 없기 때문에 2 센트를 드리겠습니다.

먼저 PowerShell에서 @AuriRahimzadeh의 명령을 관리자로 사용합니다.

New-SelfSignedCertificate -DnsName "localhost" -CertStoreLocation "cert:\LocalMachine\My"

이것은 좋지만 인증서를 신뢰할 수 없으며 다음 오류가 발생합니다. 에 설치되어 있지 않기 때문입니다 Trusted Root Certification Authorities.

여기에 이미지 설명 입력

시작하여 이것을 해결하십시오 mmc.exe.

그런 다음 다음으로 이동하십시오.

파일-> 스냅인 추가 또는 제거-> 인증서-> 추가-> 컴퓨터 계정-> 로컬 컴퓨터

Personal폴더를 확장하면 localhost인증서 가 표시됩니다 .

여기에 이미지 설명 입력

이것을 복사 Trusted Root Certification Authorities - Certificates

마지막 단계는 열 수 있습니다 Internet Information Services (IIS) Manager또는 단순히 inetmgr.exe. 귀하의 사이트에 거기에서 선택 Bindings...하고 Add...또는 Edit.... https드롭 다운에서 인증서를 설정 하고 선택합니다.

여기에 이미지 설명 입력

이제 인증서를 신뢰할 수 있습니다.

여기에 이미지 설명 입력


이동할 수있는 자체 서명 된 인증서를 생성하려는 경우 생성 http://localhost/mysite하는 방법은 다음과 같습니다.

makecert -r -n "CN=localhost" -b 01/01/2000 -e 01/01/2099 -eku 1.3.6.1.5.5.7.3.1 -sv localhost.pvk localhost.cer
cert2spc localhost.cer localhost.spc
pvk2pfx -pvk localhost.pvk -spc localhost.spc -pfx localhost.pfx

에서 http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/32bc5a61-1f7b-4545-a514-a11652f11200


I would recomment Pluralsight's tool for creating self-signed-certs: http://blog.pluralsight.com/selfcert-create-a-self-signed-certificate-interactively-gui-or-programmatically-in-net

Make your cert as a .pfx and import it into IIS. And add it as a trusted root cert authority.


Yes and no. Self signed certificates result in that warning message because the certificate was not signed by a trusted Certificate Authority. There are a few options that you can consider to remove this warning on your local machine. See the highest ranked answers to this question for details:

What do I need to do to get Internet Explorer 8 to accept a self signed certificate?

Hope this helps!


EDIT:

죄송합니다. 처음에는 귀하가 localhost에 제한되어 있다는 사실을 몰랐습니다. 아래 링크의 지침에 따라 "올바른 일반 이름으로 자체 서명 된 인증서 생성"을 시도 할 수 있습니다.

http://www.sslshopper.com/article-how-to-create-a-self-signed-certificate-in-iis-7.html

참고 URL : https://stackoverflow.com/questions/8169999/how-can-i-create-a-self-signed-cert-for-localhost

반응형