2017-09-12 17 views
2

내 간단한 클래스는 HTTPS를 통해 PEM 인증서가있는 웹 서비스를 요청할 수 있습니다.PEM 인증서가있는 HTTP 요청

require [omit verbose] 

class Api 

    def initialize 
     @ctx = OpenSSL::SSL::Context::Client.new 
     @ctx.private_key = "/home/XXXXXX/development.pem" 
     @ctx.verify_mode = LibSSL::VerifyMode::NONE 
    end 

    def customers 
     response = HTTP::Client.get "https://XXX.XXX.XXX.XXX:XXXX/api/customers", nil, nil, @ctx 
     puts response.status_code 
     puts response.body 
     puts response.inspect 
     nil 
    end 

end 

Api.new.customers 

그러나 나는 단지 401 권한 부여 크리스탈 실행 SRC/api.cr을 요구받을 수 있습니다.

+0

검증을 비활성화하면 필요는 없습니다이 줄을 추가합니다. CA가 시스템 번들에없는 경우 명시 적으로 컨텍스트에서 설정하는 것이 좋습니다. –

답변

3

certificate_chain도 설정해야합니다.

초기화 방법

@ctx.certificate_chain = "/home/XXXXXX/development.pem"