2

인증서 인증을 통해 활성 리소스를 사용하는 예를 묻습니다.Rails 3.2, activeresource 및 인증서 인증

http://apidock.com/rails/ActiveResource/Base에있는 설명서에는 예제가 없습니다. 내가 공개/개인 키를 생성

APP1 (https://app1.mauroapplications.com), APP2 (https://app2.mauroapplications.com) :

나는 두 개의 레일 통신 할 필요가 응용 프로그램이 각 애플리케이션 (RSA). APP2는 APP1 (app1.pem)과 viceversa의 공개 키를 가지고 있습니다.

제 개발 환경에서 자체 서명 된 SSL 인증서가 있습니다.

어떻게 APP2에서 ActiveResource를 확장하는 모델을 구성해야합니까? 사전에

많은 감사,

마우로

+0

같은 문제는 ... 해결책을 찾았습니까? – pencil

+0

아니요, 토큰으로 보호 된 API (http://railscasts.com/episodes/350-rest-api-versioning 및 http://railscasts.com/episodes/352-securing-an-api)로 전환했습니다. –

답변

3

다음 코드는 작동 :

class Person < ActiveResource::Base 
    self.site = 'https://api.people.com:3000/' 
    self.ssl_options = { 
    cert: OpenSSL::X509::Certificate.new(File.open('cert.pem')), 
    key: OpenSSL::PKey::RSA.new(File.open('key.pem')), 
    ca_file: 'ca.cert.pem', 
    verify_mode: OpenSSL::SSL::VERIFY_PEER 
    } 
end 

cert.pem가 검증을 위해 클라이언트 인증서, key.pem 고객의 개인 키와 ca.cert.pem CA 인증서 (인 경우 서버 인증서의).