programing

OpenSSL 및 openssl.conf 파일 읽기 오류

starjava 2023. 4. 12. 21:40
반응형

OpenSSL 및 openssl.conf 파일 읽기 오류

Windows xp 32bit를 실행하고 있다.

아래 URL에서 Opensl을 다운로드하여 설치했습니다.http://www.slproweb.com/products/Win32OpenSSL.html

그리고 다음 명령어를 사용하여 자기 서명 증명서를 작성하려고 했습니다.

openssl req -x509 -days 365 -newkey rsa:1024 -keyout hostkey.pem -nodes -out hostcert.pem

그 후 다음과 같은 오류가 발생하기 시작했다.

Unable to load config info from /usr/local/ssl/openssl.cnf

구글 검색 후 위의 명령어를 로 변경했습니다.

openssl req -config C:\OpenSSL\bin\openssl.conf -x509 -days 365 -newkey rsa:1024 -keyout hostkey.pem -nodes -out hostcert.pem

그러나 명령 프롬프트에 다음과 같은 오류가 표시됩니다.

error on line -1 of C:\OpenSSL\bin\openssl.conf
4220:error:02001002:system library:fopen:No such file or
directory:.\crypto\bio\bss_file.c:126:fopen('C:\OpenSSL\bin\openssl.conf','rb') 
4220:error:2006D080:BIO routines:BIO_new_file:no such file:.\crypto\bio\bss_file.c:129: 
4220:error:0E078072:configuration file routines:DEF_LOAD:no such file:.\crypto\conf\conf_def.c:197:

에서는, 속성도 할 수 있습니다.OPENSSL_CONF예를 들어 명령줄에서 다음과 같이 입력할 수 있습니다.

set OPENSSL_CONF=c:/libs/openssl-0.9.8k/openssl.cnf

다음을 입력하여 검증할 수 있습니다.

echo %OPENSSL_CONF%

시스템 환경 변수의 일부로 설정하여 모든 사용자와 서비스에서 기본적으로 사용할 수 있도록 할 수도 있습니다.예를 들어 Windows NT의 환경 변수Windows XP의 환경 변수 관리 방법을 참조하십시오.

이제 config location 파라미터를 전달하지 않고도 openssl 명령을 실행할 수 있습니다.

만 하면 .-config c:\your_openssl_path\openssl.cfg, 변경, 변경your_openssl_path실제 설치된 경로로 이동합니다.

4단계에서는 다음과 같이 openssl.cnf 파일을 직접 작성합니다.

링크 정지 후 편집 openssl.cnf 파일의 내용은 다음과 같습니다.

#
# OpenSSL configuration file.
#

# Establish working directory.

dir                 = .

[ ca ]
default_ca              = CA_default

[ CA_default ]
serial                  = $dir/serial
database                = $dir/certindex.txt
new_certs_dir               = $dir/certs
certificate             = $dir/cacert.pem
private_key             = $dir/private/cakey.pem
default_days                = 365
default_md              = md5
preserve                = no
email_in_dn             = no
nameopt                 = default_ca
certopt                 = default_ca
policy                  = policy_match

[ policy_match ]
countryName             = match
stateOrProvinceName         = match
organizationName            = match
organizationalUnitName          = optional
commonName              = supplied
emailAddress                = optional

[ req ]
default_bits                = 1024          # Size of keys
default_keyfile             = key.pem       # name of generated keys
default_md              = md5               # message digest algorithm
string_mask             = nombstr       # permitted characters
distinguished_name          = req_distinguished_name
req_extensions              = v3_req

[ req_distinguished_name ]
# Variable name             Prompt string
#-------------------------    ----------------------------------
0.organizationName          = Organization Name (company)
organizationalUnitName          = Organizational Unit Name (department, division)
emailAddress                = Email Address
emailAddress_max            = 40
localityName                = Locality Name (city, district)
stateOrProvinceName         = State or Province Name (full name)
countryName             = Country Name (2 letter code)
countryName_min             = 2
countryName_max             = 2
commonName              = Common Name (hostname, IP, or your name)
commonName_max              = 64

# Default values for the above, for consistency and less typing.
# Variable name             Value
#------------------------     ------------------------------
0.organizationName_default      = My Company
localityName_default            = My Town
stateOrProvinceName_default     = State or Providence
countryName_default         = US

[ v3_ca ]
basicConstraints            = CA:TRUE
subjectKeyIdentifier            = hash
authorityKeyIdentifier          = keyid:always,issuer:always

[ v3_req ]
basicConstraints            = CA:FALSE
subjectKeyIdentifier            = hash
set OPENSSL_CONF=c:/{path to openSSL}/bin/openssl.cfg

올바른 확장자를 관리합니다(cnf가 아닌 sl.cfg).

OpenSSL을 설치했습니다.http://slproweb.com/products/Win32OpenSSL.html

OpenSSL과 함께 Apache를 설치한 경우 bin 디렉터리로 이동하십시오.내 경우 D:\apache\bin.

*이러한 명령어는 openssl을 독립 실행형 상태로 설치한 경우에도 작동합니다.

다음 명령을 실행합니다.

openssl req -config d:\apache\conf\openssl.cnf -new -out d:\apache\conf\server.csr -keyout d:\apache\conf\server.pem
openssl rsa -in d:\apache\conf\server.pem -out d:\apache\conf\server.key
openssl x509 -in d:\apache\conf\server.csr -out d:\apache\conf\server.crt -req -signkey d:\apache\conf\server.key -days 365

* 개발 목적으로 사용할 수 있는 자기서명증명서가 생성됩니다.

또한 Apache가 httpd.conf 스틱에 설치되어 있는 경우 다음과 같습니다.

  <IfModule ssl_module>
    SSLEngine on
    SSLCertificateFile "D:/apache/conf/server.crt"
    SSLCertificateKeyFile "D:/apache/conf/server.key"
  </IfModule>

Apache for windows bin 폴더에서 openssl.exe를 사용했을 때 비슷한 오류가 발생했습니다.openssl.cnf 파일의 경로에 오타가 있는 -config 플래그를 지정했습니다.찾을 수 있을 것 같아

openssl req -config C:\OpenSSL\bin\openssl.conf -x509 -days 365 -newkey rsa:1024 -keyout hostkey.pem -nodes -out hostcert.pem

그래야 한다

openssl req -config "C:\OpenSSL\bin\openssl.cnf" -x509 -days 365 -newkey rsa:1024 -keyout hostkey.pem -nodes -out hostcert.pem

주의: confcnf여야 합니다.

openssl을 실행해 보세요.exe를 administrator로 사용합니다.

Git과 함께 Windows에 OpenSSL을 설치한 경우 다음 명령을 추가합니다.

-config "C:\Program Files\Git\usr\ssl\openssl.cnf"

Windows에서도 같은 문제가 발생했습니다.환경변수를 다음과 같이 설정하여 해결했습니다.

변수 이름: OPENSL_CONF 변수 값: C:(OpenSSL Directory)\bin\openssl.cnf

openssl 인스톨이 성공했을 경우는, c드라이브내의 「OPENSL」을 검색해, 설정 파일을 찾아 패스를 설정합니다.

set OPENSSL_CONF=<location where cnf is available>/openssl.cnf

나한테는 효과가 있었어.

문제는 GnuWin32 openssl과 함께 제공된 openssl.cnf 파일이 없다는 것입니다.당신이 만들어야 해요.openssl.cnf 파일의 작성 방법에 대해서는, 다음의 URL 를 참조해 주세요.

http://www.flatmtn.com/article/setting-ssl-certificates-apache

모든 것을 어떻게 할지에 대해 설명해 줄 수 있습니다.

주의사항:마지막에 백슬래시와 함께 제공되는openssl 명령어는 UNIX용입니다.Windows 의 경우: 1) 백슬래시를 삭제하고 2) 첫 번째 줄의 끝에 오도록 두 번째 줄을 위로 이동합니다.(따라서 명령어는 1개뿐입니다).

또한: 코멘트를 읽는 것은 매우 중요하다.이를 바탕으로 몇 가지 변경을 가할 수 있습니다.

이 회피책은, 업무(테크 서포트)에서 큰 도움이 되어, 어디에서라도 간단하게 실행할 수 있는 배치 파일을 작성했습니다(인스톨 할 수 있는 권한이 없었습니다).이 회피책에서는 변수를 설정하고 OpenSSL을 실행합니다.bin 폴더도 열립니다(작성 또는 수정한 파일이 저장되기 때문입니다).또, 이것은 Windows 전용입니다.

셋업 방법:

  1. 여기서 OpenSSL 바이너리를 다운로드합니다.(버전 0.9.8h에서 동작하는 것을 확인합니다.)
  2. 이 코드를 StartOpenSSL.bat 파일에 복사합니다.원하는 위치에 저장합니다.어디서든 실행할 수 있습니다.

    @echo off
    title OpenSSL
    
    cd\openssl\bin
    
    if exist "C:\openssl\share\openssl.cnf" (
    
    set OPENSSL_CONF=c:/openssl/share/openssl.cnf
    start explorer.exe c:\openssl\bin
    
    echo Welcome to OpenSSL
    
    openssl
    
    ) else (
    
    echo Error: openssl.cnf was not found
    echo File openssl.cnf needs to be present in c:\openssl\share
    pause
    
    )
    
    exit
    
  3. OpenSSL 바이너리를 다운로드한 후 OpenSSL이라는 이름의 폴더에 있는 C 드라이브에 압축을 풉니다(경로는 C:\OpenSSL).폴더 내용을 이동하지 말고 폴더로 압축을 풉니다.
  4. OpenSSL을 사용할 준비가 되었습니다.이 방법은 권한이 필요 없기 때문에 설치할 권한이 없는 Windows 사용자에게 매우 유용합니다.아까 배트 파일을 더블 클릭하여 실행하면 됩니다.

https://github.com/xgqfrms-gildata/App001/issues/3

  1. 첫 번째로, 반드시 이 시스템이openssl.cnf올바른 경로로 파일링
  2. 찾을 수 없는 경우 다운로드하여 설정 경로에 복사하십시오.
$ echo %OPENSSL_CONF%

$ set OPENSSL_CONF=C:\OpenSSL\bin\openssl.cnf

에러가 발생했을 경우는, 다음과 같이 됩니다.

회선 -1 c: cnfconfopensl.cnf 오류

config에서 back slash에서 front slash로 변경해 보겠습니다.

관리자 권한으로 이 명령을 실행하여 읽기 권한이 있는 위치에 구성 파일을 복사하고 -config 매개 변수를 사용하여 경로를 지정합니다.

이 문제가 오래되었다는 것을 알지만, 제가 어떻게 풀었는지 알려줄게.

복사했습니다.openssl.cnf에서 줄서다bin상위 디렉토리로의 디렉토리:C:/Openssl/openssl.cnf대신C:/Openssl/bin/openssl.cnf잘 작동했어요.

오래된 것은 알지만, Visual Studio를 사용하는 다른 제품도 도움이 될 것으로 생각됩니다.나는 이것을 내가 찾을 수 없는 다른 게시물에서 읽었다.

메모장++에서 설정을 열고 인코딩이 UTF-8인지 확인합니다(UTF-8-BOM*이 아님).

이렇게 하면 검색이나 시행착오를 많이 줄일 수 있을 텐데...

나도 같은 문제에 직면해 있었다.이 문제를 해결하기 위한 단계는 다음과 같습니다.

  1. openssl 버전 확인

openssl 버전

  1. 사용하시는 버전이 이하인 경우

OpenSSL 1.1.1h 2020년 9월 22일

  1. 아래 링크로 이동하여 최신 버전의 openssl을 다운로드하십시오.openssl 윈도우즈 설치 관리자
  2. 설치 후 시스템 경로의 'PATH' 변수 상단에 openssl 경로를 추가합니다.
  3. 새로운 명령 프롬프트를 열고 1단계에서 명령을 실행하여 버전이 최신인지 확인합니다.
  4. 이것으로 명령어를 다시 실행할 준비가 되었습니다.이번에 동작합니다.

언급URL : https://stackoverflow.com/questions/7360602/openssl-and-error-in-reading-openssl-conf-file

반응형