私は、クライアントブラウザにcertをインストールする必要があるアプリを書いています。私はこれを "Context"オブジェクトのPyOpenSSLドキュメントで見つけましたが、何とかコールバックが証明書を検証する方法については何も見えません。PyOpenSSLでのクライアント証明書の検証
set_verify(mode, callback) Set the verification flags for this Context object to mode and specify that callback should be used for verification callbacks. mode should be one of VERIFY_NONE and VERIFY_PEER. If VERIFY_PEER is used, mode can be OR:ed with VERIFY_FAIL_IF_NO_PEER_CERT and VERIFY_CLIENT_ONCE to further control the behaviour. callback should take five arguments: A Connection object, an X509 object, and three integer variables, which are in turn potential error number, error depth and return code. callback should return true if verification passes and false otherwise.
は、私は私の(自己署名)Contextオブジェクトを言っている鍵である(下記参照)ので、ライブラリをチェックするために、私はそれが十分ではない理由を私は理解していないと思う場合は、クライアントによって提示された証明書有効なものです。このコールバック関数では、何をすべきですか?
class SecureAJAXServer(PlainAJAXServer):
def __init__(self, server_address, HandlerClass):
BaseServer.__init__(self, server_address, HandlerClass)
ctx = SSL.Context(SSL.SSLv23_METHOD)
ctx.use_privatekey_file ('keys/server.key')
ctx.use_certificate_file('keys/server.crt')
ctx.set_session_id("My_experimental_AJAX_Server")
ctx.set_verify(SSL.VERIFY_PEER | SSL.VERIFY_FAIL_IF_NO_PEER_CERT | SSL.VERIFY_CLIENT_ONCE, callback_func)
self.socket = SSL.Connection(ctx, socket.socket(self.address_family, self.socket_type))
self.server_bind()
self.server_activate()
警告:それはSSLに来るとき、私のQは私の総跛行、認識の甘さ、および/または理解の基本的な欠如を明らかにするので、もしDEF、ここでの楽しみのためにプロのないコーディングあまりにもラフにならないでください!
感謝:)
ロジャー