2010-01-18 2 views
3

SSL 포트에서 수신 대기중인 서버를 설정했습니다. 연결할 수 있고 적절한 자격 증명을 사용하여 서비스에 액세스 할 수 있습니다 (아래 예에서 에코 서비스)(코드의 어느 시점에서) pyAMF 클라이언트가 SSL 인증서를 허용합니까?

아래 코드는 제대로 작동하지만 클라이언트가 허용하는 지점을 으로 이해할 수 없습니다. 인증서

서버 :

import os.path 
import logging 
import cherrypy 
from pyamf.remoting.gateway.wsgi import WSGIGateway 

logging.basicConfig(
    level=logging.DEBUG, 
    format='%(asctime)s %(levelname)-5.5s [%(name)s] %(message)s' 
) 

def auth(username, password): 
    users = {"user": "pwd"} 
    if (users.has_key(username) and users[username] == password): 
      return True 
    return False 

def echo(data): 
    return data 

class Root(object): 
    @cherrypy.expose 
    def index(self): 
      return "This is your main website" 

gateway = WSGIGateway({'myservice.echo': echo,}, logger=logging, debug=True, authenticator=auth) 

localDir = os.path.abspath(os.path.dirname(__file__)) 
CA = os.path.join(localDir, 'new.cert.cert') 
KEY = os.path.join(localDir, 'new.cert.key') 
global_conf = {'global': {'server.socket_port': 8443, 
         'environment': 'production', 
         'log.screen': True, 
         'server.ssl_certificate': CA, 
         'server.ssl_private_key': KEY}} 

cherrypy.tree.graft(gateway, '/gateway/') 
cherrypy.quickstart(Root(), config=global_conf) 

클라이언트 :이 프로그램을 실행할 때 이제

import logging 
from pyamf.remoting.client import RemotingService 

logging.basicConfig(
    level=logging.DEBUG, 
    format='%(asctime)s %(levelname)-5.5s [%(name)s] %(message)s' 
) 

client = RemotingService('https://localhost:8443/gateway', logger=logging) 
client.setCredentials('user', 'pwd') 

service = client.getService('myservice') 
print service.echo('Echo this') 

, 그것은 실행 OK 클라이언트 로그는 아래와 같다 :

2010-01-18 00:50:56,323 INFO [root] Connecting to https://localhost:8443/gateway 
2010-01-18 00:50:56,323 DEBUG [root] Referer: None 
2010-01-18 00:50:56,323 DEBUG [root] User-Agent: PyAMF/0.5.1 
2010-01-18 00:50:56,323 DEBUG [root] Adding request myservice.echo('Echo this',) 
2010-01-18 00:50:56,324 DEBUG [root] Executing single request: /1 
2010-01-18 00:50:56,324 DEBUG [root] AMF version: 0 
2010-01-18 00:50:56,324 DEBUG [root] Client type: 0 
2010-01-18 00:50:56,326 DEBUG [root] Sending POST request to /gateway 
2010-01-18 00:50:56,412 DEBUG [root] Waiting for response... 
2010-01-18 00:50:56,467 DEBUG [root] Got response status: 200 
2010-01-18 00:50:56,467 DEBUG [root] Content-Type: application/x-amf 
2010-01-18 00:50:56,467 DEBUG [root] Content-Length: 41 
2010-01-18 00:50:56,467 DEBUG [root] Server: PyAMF/0.5.1 Python/2.5.2 
2010-01-18 00:50:56,467 DEBUG [root] Read 41 bytes for the response 
2010-01-18 00:50:56,468 DEBUG [root] Response: <Envelope amfVersion=0 clientType=0> 
(u'/1', <Response status=/onResult>u'Echo this'</Response>) 
</Envelope> 
2010-01-18 00:50:56,468 DEBUG [root] Removing request: /1 
Echo this 

라인 2010-01-18 00 : 50 : 56,467 DEBUG [루트] 반응이 너무 짧기 때문에가 의심스러운 응답 41 바이트 읽기 (인증서가 ~ 1K입니다) 그리고 나는 인증서 전송이 디버그 로그에있을 것으로 기대합니다.

질문 : 클라이언트가 인증서를 수락하는 시점은 언제입니까? 기본적으로 저장 위치는 어디입니까? 어떤 구성 매개 변수가 기본 위치를 설정합니까?

답변

2

PyAMF는 원격 요청을 처리하기 위해 후드 아래에서 httplib을 사용합니다. https://을 통해 연결하는 경우 httplib.HTTPSConnection은 에 대한 connection 특성으로 사용됩니다.

그것은이 문서에서 언급하는 (HTTPSConnection 참조에서) :

참고 :이 기본적으로 무시됩니다 귀하의 질문에 인증서에 대한 응답으로,

그래서 어떤 인증서 확인을하지 않습니다, 심지어 key_file/cert_file 인수를 connection에 제공하는 경우에도 마찬가지입니다.

실제 connect 메소드가 호출 될 때 수행된다 무시 - .. 요구가 실제로 게이트웨이에 이루어질 때

[루트] POST 요청을 보내는/게이트웨이

Read 41 bytes for the response 암호화되지 않은 http 응답 길이입니다.

이 답변에는 사용자가 필요로하는 모든 정보가 포함되어 있지는 않지만 현재보고있는 동작에 대해 설명해야합니다.

+0

@njoyce : 설명과 링크에 감사드립니다. 이것은이 문제에 대해 밝히고 있습니다. 나는 그것이 인증서 수락을 강제하는 것이 가능한지 궁금해. 브라우저를 통해 Flex 응용 프로그램에서이 게이트웨이에 액세스하려고하면 인증서를 수락하도록 요청 받게됩니다. RemotingService API를 보면 파이썬 클라이언트가 cert를 받아들이도록 강제하는 방법을 알지 못했다. 생각을 공유하십시오. –

관련 문제