OpenSSL : PEM 루틴 : PEM_read_bio : 시작 줄 없음 : pem_lib.c : 703 : 예상 : TRUSTED CERTIFICATE [닫힘]
Stunnel의 CApath 디렉터리에 게시 할 파일의 해시 이름이 필요합니다. 이 디렉토리에 인증서가 몇 개 있으며 잘 작동하고 있습니다. 또한 서버 sert 및 서버 키가 있습니다.
cert = c:\Program Files (x86)\stunnel\server_cert.pem
key = c:\Program> Files (x86)\stunnel\private\server_key.pem
새 인증서의 해시를 계산하려고하면 오류가 발생합니다.
/etc/pki/tls/misc/c_hash cert.pem
unable to load certificate 140603809879880:error:0906D06C:PEM
routines:PEM_read_bio:no start line:pem_lib.c:703:Expecting: TRUSTED CERTIFICATE
내가 이해 한대로 내 인증서에 서명해야하지만 어떻게 할 수 있는지 이해가 안 돼요. 솔루션을 제공하십시오.
추신:
메시지
unable to load certificate 140603809879880:error:0906D06C:PEM
routines:PEM_read_bio:no start line:pem_lib.c:703:Expecting: TRUSTED CERTIFICATE:
cert.pem에 대해 c_hash 를 만들 때 게시 됨 이것은 server_cert.pem이 아니라 Root_CA이며 다음과 같은 내용입니다.
-----BEGIN CERTIFICATE-----
...6UXBNSDVg5rSx60=..
-----END CERTIFICATE-----
내가 쓸 때
openssl x509 -noout -text -in cert.pem
콘솔 패널에 다음 정보가 표시됩니다.
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 1 (0x1)
Signature Algorithm: sha1WithRSAEncryption
Issuer: C=BE, ST=BB, L=BB, O=BANKSYS NV, OU=SCY, CN=TEST Root CA
Validity
Not Before: May 31 08:06:40 2005 GMT
Not After : May 31 08:06:40 2020 GMT
Subject: C=BE, ST=BB, L=BB, O=BB NV, OU=SCY, CN=TEST Root CA
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (2048 bit)
Modulus:
00:82:c8:58:1e:e5:7a:b2:63:a6:15:bd:f9:bb:1f:
............
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Basic Constraints: critical
CA:TRUE
X509v3 Key Usage: critical
Certificate Sign, CRL Sign
X509v3 Subject Key Identifier:
76:70:AB:92:9B:B1:26:CE:9E:93:D8:77:4F:78:0D:B8:D4:6C:DA:C6
Signature Algorithm: sha1WithRSAEncryption
2c:7e:bd:3f:da:48:a4:df:8d:7c:96:58:f7:87:bd:e7:16:24:
...............
Since you are on Windows, make sure that your certificate in Windows "compatible", most importantly that it doesn't have
^M
in the end of each lineIf you open it it will look like this:
-----BEGIN CERTIFICATE-----^M MIIDITCCAoqgAwIBAgIQL9+89q6RUm0PmqPfQDQ+mjANBgkqhkiG9w0BAQUFADBM^M
To solve "this" open it with
Write
or Notepad++ and have it convert it to Windows "style"Try to run
openssl x509 -text -inform DER -in server_cert.pem
and see what the output is, it is unlikely that a private/secret key would be untrusted, trust only is needed if you exported the key from a keystore, did you?
Another possible cause of this is trying to use the x509 module on something that is not x509
The server certificate is x509 format, but the private key is rsa
So,
openssl rsa -noout -text -in privkey.pem
openssl x509 -noout -text -in servercert.pem
My situation was a little different. The solution was to strip the .pem from everything outside of the CERTIFICATE and PRIVATE KEY sections and to invert the order which they appeared. After converting from pfx to pem file, the certificate looked like this:
Bag Attributes
localKeyID: ...
issuer=...
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
Bag Attributes
more garbage...
-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----
After correcting the file, it was just:
-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
I had the same issue using Windows, got if fixed by opening it in Notepad++ and changing the encoding from "UCS-2 LE BOM" to "UTF-8".
My mistake was simply using the CSR file instead of the CERT file.
Change encoding in notepad++ UTF-8 with BOM. That is how it worked for me
You can get this misleading error if you naively try to do this:
[clear] -> Private Key Encrypt -> [encrypted] -> Public Key Decrypt -> [clear]
Encrypting data using a private key is not allowed by design.
You can see from the command line options for open ssl that the only options to encrypt -> decrypt
go in one direction public -> private
.
-encrypt encrypt with public key
-decrypt decrypt with private key
The other direction is intentionally prevented because public keys basically "can be guessed." So, encrypting with a private key means the only thing you gain is verifying the author has access to the private key.
The private key encrypt -> public key decrypt
direction is called "signing" to differentiate it from being a technique that can actually secure data.
-sign sign with private key
-verify verify with public key
Note: my description is a simplification for clarity. Read this answer for more information.
'IT박스' 카테고리의 다른 글
PHP를 사용하여 크론 작업을 만드는 방법은 무엇입니까? (0) | 2020.09.04 |
---|---|
GitHub에서 프로젝트 다운로드 수를 확인하는 방법은 무엇입니까? (0) | 2020.09.04 |
dplyr 요약 : 출력에서 길이가 0 인 그룹을 유지하려면 ".drop = FALSE"와 동일합니다. (0) | 2020.09.04 |
프로덕션 환경에서 스프링 부트 실행 가능 jar를 어떻게 실행합니까? (0) | 2020.09.04 |
배열에서 clone ()을 호출해도 내용이 복제됩니까? (0) | 2020.09.04 |