Program Tip

Windows에서 "인증서 확인 실패"를 해결하는 방법은 무엇입니까?

programtip 2020. 10. 22. 22:22
반응형

Windows에서 "인증서 확인 실패"를 해결하는 방법은 무엇입니까?


Google 서비스에 대한 OAuth에 signet을 사용하려고합니다. 그리고이 오류가 발생합니다.

SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

다음 질문에 따라 :

해결책은 SSL 을 수정 ca_path하거나 설정하는 것 VERIFY_NONE입니다 .

ca_path게시 수정 사항은 Linux (포트 설치)에서만 작동하며에 대한 수정 사항 VERIFY_NONE은 패러데이 용인 것 같습니다.

Windows / signet gem에 대한 솔루션이 있습니까?


실제로 내가 발견 한 가장 좋은 방법은 하나의 gem이 아닌 Ruby 자체의 창에서 다음을 수행하는 것입니다.

  1. 다운로드 https://curl.haxx.se/ca/cacert.pem을 C로 : \ railsinstaller \ cacert.pem. 텍스트 파일이 아닌 .pem 파일로 저장해야합니다.
  2. 컴퓨터-> 고급 설정-> 환경 변수로 이동하십시오.
  3. 새 시스템 변수를 만듭니다.

    변수 : SSL_CERT_FILE 값 : C : \ RailsInstaller \ cacert.pem

  4. Rails 서버 명령 프롬프트 등을 포함하여 모든 명령 프롬프트를 닫습니다.

  5. 새 ruby ​​irb 프롬프트를 시작하고 다음을 시도하십시오.

    $irb>require 'open-uri'
    $irb>open('https://www.gmail.com')
    

이제 모두 잘 작동합니다.


Windows 용 솔루션, 몇 가지 다른 답변에서 함께 정리했습니다.

  1. https://curl.haxx.se/ca/cacert.pem을 다운로드 하여 YOUR_APP / lib / assets (또는 어디에 있든)에 넣으십시오.
  2. 에서 설정 / 초기화 / omniauth.rb :

     #config/initializers/omniauth.rb
    Rails.application.config.middleware.use OmniAuth::Builder do
      provider :facebook, CUSTOMER_KEY, CUSTOMER_SECRET, {client_options: {ssl: {ca_file: Rails.root.join('lib/assets/cacert.pem').to_s}}}
    end
    
  3. 분명히 서버를 다시 시작하십시오.

각주 : cacert.pem 파일에서 불필요한 인증서를 많이 잘라내어 크기를 줄일 수 있습니다. 개발을 위해서만이 솔루션이 필요한 경우 프로젝트 외부에 파일을 저장하고if Rails.env.development?client_optionselsehash_없이 client_options hash__provider 줄을 사용하여_provider 줄을 수행 할 수 있습니다.end


너무 많은 검색과 시간 낭비 끝에 Ruby에서 Windows와 함께이 문제를 해결할 수있는 매우 간단한 해결책을 찾았습니다.

두 가지 간단한 단계 :

  1. 명령 프롬프트에서 다음을 작성하십시오. C:\gem install certified

  2. 당신에 rb파일 추가 :require 'certified'

그게 다야.


rubygems 패키지 관리 프레임 워크를 업데이트하면 Windows 7에서이 문제가 해결되었습니다.

https://rubygems.org/pages/download

gem update --system          # may need to be administrator or root

예, initializers 폴더의 omniouth.rb 파일을 다음과 같이 설정했습니다.

provider :facebook, FACEBOOK_KEY, FACEBOOK_SECRET, {:client_options => {:ssl => {:verify => false}}}

그리고 이것은 이제 잘 작동하는 것 같습니다. 그러나 이것을 프로덕션에 사용하지 마십시오 .


https : // 대신 http : // URL을 사용하면이 작업이 더 쉬워집니다.

ruby 명령 줄에서 다음 명령 줄을 사용하여 gem 소스를 http://rubygems.org/변경합니다.

gem sources -a http://rubygems.org/

rubygems-update 다운로드 페이지로 이동 : https://rubygems.org/gems/rubygems-update

다운로드 링크를 클릭하면 rubygems-update-2.6.7.gem이라는 파일이 다운로드됩니다. 명령 줄에서 .gem 파일을 다운로드 한 디렉토리로 이동하고 다음을 입력합니다.

gem install rubygems-update-2.6.7.gem

(또는 최신 버전 인 경우 파일 이름이 무엇이든)

그런 다음 다음을 입력하십시오.

update_rubygems

다음을 사용하여 업데이트되었는지 확인할 수 있습니다.

gem --version

DevDude의 솔루션에 추가하지만 Windows Powershell 사용 :

http://curl.haxx.se/ca/cacert.pem 을 c : \ railsinstaller \ cacert.pem에 다운로드합니다 .

powershell 프롬프트에서 :

$env:SSL_CERT_FILE = 'c:\RailsInstaller\cacert.pem'

그런 다음 gem update성공적으로 실행할 수있었습니다

참고 : 프로필에서 환경 변수를 간단히 정의 할 수 있습니다. notepad $profile


Windows 시스템에서 rails 5를 설정하려고 할 때이 오류가 발생했는데, rubygem 버전을 2.6.7로 업데이트해야했고 작동했습니다.

1 단계 아래에서 rubygem 다운로드

https://rubygems.org/downloads/rubygems-update-2.6.7.gem

2 단계-다운로드 한 rubygems를 가리켜 설치

gem install --local C:\rubygems-update-2.6.7.gem

3 단계-새 버전이 2.6.7인지 확인

gem --version

4 단계-이제 rubygems-update gem을 안전하게 제거합니다.

gem uninstall rubygems-update -x

5 단계는 레일 5를 다시 설치하려고했습니다.

gem install rails --version 5.0.0

매력처럼 작동했습니다!

http://guides.rubygems.org/ssl-certificate-update/#installing-using-update-packages 에서 정보를 얻었습니다.


I was able to eliminate the PATH or SYSTEM VARIABLE setting mentioned above by importing the certificate as a Trusted Authority.

  1. Invoke certmgr.msc
  2. Right-click the Trusted Root Certificate Authority folder.
  3. Select "All Tasks"
  4. Select "Import"
  5. Select All Files in file type dropdown and select the cacert.pem file.
  6. You should receive a message "Import Successful"

I believe the correct answer is to update your gem installer: rubygems-update. The explanation for why this is needed is found at: Ssl Certificate Updates


save your cacert.pmp file from https://curl.haxx.se/ca/cacert.pem and then add this file to location yourruby-installation folder\lib\ruby\2.3.0\rubygems\ssl_certs

for example:C:\Ruby23\lib\ruby\2.3.0\rubygems\ssl_certs


This helped me: https://coderwall.com/p/ubl6iw/fix-ssl_connect-returned-1-errno-0-state-sslv3-read-server-certificate-b-certificate-verify-failed-openssl-ssl-sslerror My ruby on rails project is posting data to an api internally, and it cannot verify the internal certificate. These lines helped:

require 'https'

http = Net::HTTP.new('example.com', 443)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER

http.cert_store = OpenSSL::X509::Store.new
http.cert_store.set_default_paths
http.cert_store.add_file('/path/to/internal.cert.pem')

Hope this can help.


I was also facing this issue when I installed older ruby versions. When I installed the latest Ruby version this problem went away. So basically the SSL certificate needed to be updated.


For people who are using rails 4.

Add this in devise.rb

require "omniauth-google-oauth2"
config.omniauth :google_oauth2, "CLIENT_ID", "CLIENT_SECRET", { access_type: "offline", approval_prompt: "", :client_options => {:ssl => {:verify => false}} }

참고URL : https://stackoverflow.com/questions/5720484/how-to-solve-certificate-verify-failed-on-windows

반응형