Google Chrome에서 "인증서를 가져올 때 개인 키가 없거나 유효하지 않습니다."

Google Chrome에서 "인증서를 가져올 때 개인 키가 없거나 유효하지 않습니다."

https localhost에서 내 웹앱을 테스트하고 싶습니다. 불행히도 크롬에서 인증서 경고를 제거하는 것은 불가능해 보입니다. 먼저 다음과 같이 인증서를 생성했습니다.

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/localhost-selfsigned.key -out /etc/ssl/certs/localhost-selfsigned.crt

그런 다음 Chrome에 설정 > 고급 > 인증서 관리 -> 가져오기를 추가하고 싶었습니다. 이전에 생성된 .crt 파일을 가져오려고 했는데 얻은 것은 다음과 같습니다.

인증서 가져오기 오류: 이 클라이언트 인증서의 개인 키가 누락되었거나 유효하지 않습니다.

나는 그것을 봤지만 도움이되는 것을 찾지 못했습니다.

또한 Allow-insecure-localhost 플래그를 활성화하고 Chrome을 열려고 시도했지만 --ignore-certificate-errors여전히 경고와 깨진 https가 표시됩니다.

다른 방법이 있습니까? 아니면 인증서에 문제가 있습니까?

답변1

내 생각에 당신이 하려는 것은 잘못된 인증서 저장소에 추가하는 것입니다. "귀하의 인증서" 아래에 추가하려고 하면 시간이 많이 소요될 것입니다. 해당 탭은 신원 인증서를 추가하기 위한 것입니다. 브라우저의 신원을 확인하기 위해 브라우저가 서버에 제공하는 것입니다.

귀하의 설명에 따르면 귀하가 하고 싶은 일은 브라우저가 서버 측에 있을 자체 서명된 인증서를 신뢰하도록 하는 것입니다. 이 경우 "당국" 탭에 추가해야 합니다.

답변2

나에게 효과가 있었던 것은

  • CA 설정
  • 이 CA를 사용하여 내 인증서에 서명한 다음
  • CA 키를 Chrome(기관)으로 가져오기

나한테서 절차를 받았어.이것SO에 대답하십시오.

내 특정 문제는 다단계 하위 도메인을 제공하는 것이었으므로 해당 각도에서 살펴보겠습니다.

하위 도메인:

  • bar.fooz.mydomain.com
  • foo.fooz.mydomain.com
  1. 인증 기관 되기
export CA=myca
# you probably want to have this in its own directory
mdkir /etc/ssl/$CA && cd /etc/ssl/$CA

# generate private key
openssl genrsa -des3 -out $CA.key 2048

# generate root certificate
openssl req -x509 -new -nodes -key $CA.key -sha256 -days 825 -out $CA.pem
  1. CA 서명 인증서 만들기
export NAME=fooz.mydomain.com
# if CA files were in a separate directory
cd .. && mkdir /etc/ssl/$NAME && cd /etc/ssl/$NAME

# generate private key
openssl genrsa -out $NAME.key 2048

# Create a certificate-signing request
# Once prompted, set FQDN to the value of $NAME
openssl req -new -key $NAME.key -out $NAME.csr

# Create a config file for the extensions
>$NAME.ext cat <<-EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = $NAME # Be sure to include the domain name here because Common Name is not so commonly honoured by itself
# Optionally, add additional domains (I've added a subdomain here)
DNS.2 = foo.$NAME
DNS.3 = bar.$NAME
IP.1 = 192.168.0.13 # (Optional, but probably important), add an IP address (if the connection which you have planned requires it)
EOF

# Create the signed certificate
openssl x509 -req -in $NAME.csr -CA $CA.pem -CAkey $CA.key -CAcreateserial -out $NAME.crt -days 825 -sha256 -extfile $NAME.ext
  1. 파일 을 다운로드 $CA.pem하고 브라우저에서 권한으로 가져옵니다.
    1. Chrome settings (Settings > Privacy and Security > Security > Manage certificates > Authorities > Import). Check Trust this certificate for identifying websites
    2. Firefox: Preferences > Privacy and Security > Certificates > View Certificates > Authorities > import. Check Trust this CA to identify websites
  1. 브라우저를 다시 시작하세요(Firefox는 다시 시작할 필요 없이 작동했습니다).

답변3

Chrome에서는 인증서, 중간 인증서 및 개인 키를 암호화 가능한 단일 파일에 저장하는 데 사용되는 PKCS12 형식 파일을 기대합니다. 이러한 파일은 일반적으로 .p12.pfx확장자를 갖습니다.

하나를 생성하려면 아래 명령을 사용하십시오.

openssl pkcs12 -export -inkey ./sample.key -in ./sample.crt -out ./sample.p12

이 명령은 생성된 파일을 Chrome으로 가져오는 동안 기억하고 사용해야 하는 비밀번호를 묻습니다 p12.

관련 정보