@@ -34,9 +34,6 @@ Spring Python currently supports and requires the installation of at least one o
3434* `Hessian <http://hessian.caucho.com/ >`_ - support for Hessian has just started. So far, you can call
3535 Python-to-Java based on libraries released from Caucho.
3636
37- * :ref: `Secure XML-RPC <remoting-secure-xml-rpc >` needs the installation of
38- `PyOpenSSL <http://pypi.python.org/pypi/pyOpenSSL >`_
39-
4037Remoting with PYRO (Python Remote Objects)
4138------------------------------------------
4239
@@ -478,9 +475,9 @@ implemented in other languages and technologies.
478475To aid with better understanding of how the components work out of the box,
479476you can download :ref: `sample keys and certificates <remoting-secure-xml-rpc-sample-keys-and-certificates >`
480477prepared by the Spring Python team.
481- Be sure ** not ** to ever use it for anything serious outside your testing environment,
482- they are working and functional but because of private keys being available for
483- download they should ** only ** be used for learning of how Spring Python's
478+ Be sure not to ever use the sample keys & certificates for anything serious outside your
479+ testing environment, they are working and functional but because of private keys being available for
480+ download they should only be used for learning of how Spring Python's
484481secure XML-RPC works.
485482
486483Encrypted connection only
@@ -505,9 +502,9 @@ one of CAs the client is aware of::
505502 # -*- coding: utf-8 -*-
506503
507504 # Spring Python
508- from springpython.remoting.xmlrpc import SSLXMLRPCServer
505+ from springpython.remoting.xmlrpc import SSLServer
509506
510- class MySSLServer(SSLXMLRPCServer ):
507+ class MySSLServer(SSLServer ):
511508 def __init__(self, *args, **kwargs):
512509 super(MySSLServer, self).__init__(*args, **kwargs)
513510
@@ -516,23 +513,26 @@ one of CAs the client is aware of::
516513
517514 host = "localhost"
518515 port = 8000
519- key = "./server-key.pem"
520- cert = "./server-cert.pem"
516+ keyfile = "./server-key.pem"
517+ certfile = "./server-cert.pem"
521518
522- server = MySSLServer(host, port, key, cert, verify_depth=2 )
519+ server = MySSLServer(host, port, keyfile, certfile )
523520 server.serve_forever()
524521
525522::
526523
527524 # -*- coding: utf-8 -*-
528525
526+ # stdlib
527+ import ssl
528+
529529 # Spring Python
530- from springpython.remoting.xmlrpc import SSLXMLRPCClient
530+ from springpython.remoting.xmlrpc import SSLClient
531531
532532 server_location = "https://localhost:8000/RPC2"
533533 ca_certs = "./ca-chain.pem"
534534
535- client = SSLXMLRPCClient (server_location, ca_certs= ca_certs)
535+ client = SSLClient (server_location, ca_certs)
536536
537537 print client.pow(41, 3)
538538
@@ -549,13 +549,13 @@ known to the client::
549549
550550 # -*- coding: utf-8 -*-
551551
552- # Spring Python
553- from springpython.remoting.xmlrpc import SSLXMLRPCServer
552+ # stdlib
553+ import ssl
554554
555- # PyOpenSSL
556- from OpenSSL import SSL
555+ # Spring Python
556+ from springpython.remoting.xmlrpc import SSLServer
557557
558- class MySSLServer(SSLXMLRPCServer ):
558+ class MySSLServer(SSLServer ):
559559 def __init__(self, *args, **kwargs):
560560 super(MySSLServer, self).__init__(*args, **kwargs)
561561
@@ -564,27 +564,26 @@ known to the client::
564564
565565 host = "localhost"
566566 port = 8000
567- key = "./server-key.pem"
568- cert = "./server-cert.pem"
567+ keyfile = "./server-key.pem"
568+ certfile = "./server-cert.pem"
569569 ca_certs = "./ca-chain.pem"
570570
571- server = MySSLServer(host, port, key, cert, ca_certs, verify_options=SSL.VERIFY_PEER|SSL.VERIFY_FAIL_IF_NO_PEER_CERT,
572- verify_depth=2)
571+ server = MySSLServer(host, port, keyfile, certfile, ca_certs, cert_reqs=ssl.CERT_REQUIRED)
573572 server.serve_forever()
574573
575574::
576575
577576 # -*- coding: utf-8 -*-
578577
579578 # Spring Python
580- from springpython.remoting.xmlrpc import SSLXMLRPCClient
579+ from springpython.remoting.xmlrpc import SSLClient
581580
582581 server_location = "https://localhost:8000/RPC2"
583- key = "./client-key.pem"
584- cert = "./client-cert.pem"
582+ keyfile = "./client-key.pem"
583+ certfile = "./client-cert.pem"
585584 ca_certs = "./ca-chain.pem"
586585
587- client = SSLXMLRPCClient (server_location, key_file=key, cert_file=cert, ca_certs=ca_certs )
586+ client = SSLClient (server_location, ca_certs, keyfile, certfile )
588587
589588 print client.pow(41, 3)
590589
@@ -596,22 +595,23 @@ Server requires the client to have a certificate and checks its fields
596595
597596Same as above (both sides need to have certificates signed off by trusted CAs)
598597but this time the server inspects the client certificate’s fields and lets it
599- in only they match the configuration it was fed with. In the example below
600- *commonName * must be *Client *, *Organization * must be *The Sample Company * and the
601- *State * must be *New York *. Server checks for both their existance and value and
602- if there’s any mismatch the connection won’t be established in which case the
603- error reason will be logged on the server side but no details of the error
598+ in only if they match the configuration it was fed with. In the example below
599+ *commonName * must be *My Client *, *organizationName * must be *My Company * and the
600+ *stateOrProvinceName * must be *My State *. Server checks for both their existance and value and
601+ if there’s any mismatch the connection will be dropped (client will receive a socket
602+ error) and the error reason will be logged on the server side but no details of the error
604603will be leaked to the client::
605604
606605 # -*- coding: utf-8 -*-
607606
608- # Spring Python
609- from springpython.remoting.xmlrpc import SSLXMLRPCServer
607+ # stdlib
608+ import logging
609+ import ssl
610610
611- # PyOpenSSL
612- from OpenSSL import SSL
611+ # Spring Python
612+ from springpython.remoting.xmlrpc import SSLServer
613613
614- class MySSLServer(SSLXMLRPCServer ):
614+ class MySSLServer(SSLServer ):
615615 def __init__(self, *args, **kwargs):
616616 super(MySSLServer, self).__init__(*args, **kwargs)
617617
@@ -620,32 +620,31 @@ will be leaked to the client::
620620
621621 host = "localhost"
622622 port = 8000
623- key = "./server-key.pem"
624- cert = "./server-cert.pem"
625- ca = "./ca-chain.pem"
623+ keyfile = "./server-key.pem"
624+ certfile = "./server-cert.pem"
625+ ca_certs = "./ca-chain.pem"
626+ verify_fields = {"commonName": "My Client", "organizationName":"My Company",
627+ "stateOrProvinceName":"My State"}
626628
627- verify_fields = {"CN": "Client", "O":"The Sample Company", "ST":"New York"}
629+ logging.basicConfig(level=logging.ERROR)
628630
629- server = MySSLServer(host, port, key, cert, ca, verify_options=SSL.VERIFY_PEER|SSL.VERIFY_FAIL_IF_NO_PEER_CERT ,
630- verify_fields=verify_fields, verify_depth=2 )
631+ server = MySSLServer(host, port, keyfile, certfile, ca_certs, cert_reqs=ssl.CERT_REQUIRED ,
632+ verify_fields=verify_fields)
631633 server.serve_forever()
632634
633635::
634636
635637 # -*- coding: utf-8 -*-
636638
637639 # Spring Python
638- from springpython.remoting.xmlrpc import SSLXMLRPCClient
640+ from springpython.remoting.xmlrpc import SSLClient
639641
640642 server_location = "https://localhost:8000/RPC2"
641- key = "./client-key.pem"
642-
643- # Make sure the commonName is set to what the server requires.
644- cert = "./client-cert.pem"
645-
643+ keyfile = "./client-key.pem"
644+ certfile = "./client-cert.pem"
646645 ca_certs = "./ca-chain.pem"
647646
648- client = SSLXMLRPCClient (server_location, key_file=key, cert_file=cert, ca_certs=ca_certs )
647+ client = SSLClient (server_location, ca_certs, keyfile, certfile )
649648
650649 print client.pow(41, 3)
651650
0 commit comments