1010class WssePlugin (MessagePlugin ):
1111 """Suds message plugin that performs WS-Security signing and encryption.
1212
13- Encrypts and signs outgoing messages (the soap:Body and the wsu:Timestamp
14- security token, which must be present); decrypts and verifies signature on
15- incoming messages.
13+ Encrypts (optional) and signs outgoing messages (the soap:Body and the
14+ wsu:Timestamp security token, which must be present); decrypts and verifies
15+ signature on incoming messages.
16+ Encryption is done if their_certfile is set.
1617
1718 Uses X509 certificates for both encryption and signing. Requires our cert
1819 and its private key, and their cert (all as file paths).
@@ -39,7 +40,13 @@ class WssePlugin(MessagePlugin):
3940 only the first child element of the soap:Body will be encrypted).
4041
4142 """
42- def __init__ (self , keyfile , certfile , their_certfile ):
43+ def __init__ (self , keyfile , certfile , their_certfile = None ):
44+ """
45+ @param keyfile path to the private key to sign the content
46+ @param certfile path to the certificate to sign the content
47+ @param their_certfile Optional, path to the recipient certificate to
48+ encrypt, if not set no encryption is done
49+ """
4350 self .keyfile = keyfile
4451 self .certfile = certfile
4552 self .their_certfile = their_certfile
@@ -48,7 +55,8 @@ def sending(self, context):
4855 """Sign and encrypt outgoing message envelope."""
4956 context .envelope = sign (
5057 context .envelope , self .keyfile , self .certfile )
51- context .envelope = encrypt (context .envelope , self .their_certfile )
58+ if their_certfile != None :
59+ context .envelope = encrypt (context .envelope , self .their_certfile )
5260
5361 def received (self , context ):
5462 """Decrypt and verify signature of incoming reply envelope."""
0 commit comments