Skip to content

Commit 1f03771

Browse files
committed
Create SIGNER in create_message to avoid thread conflicts in case of different key types
Signed-off-by: kimbeelen <kbeelen@infiniot.nl>
1 parent 65c8e07 commit 1f03771

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

openleadr/messaging.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333
import logging
3434
logger = logging.getLogger('openleadr')
3535

36-
SIGNER = XMLSigner(method=methods.detached,
37-
c14n_algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315")
38-
SIGNER.namespaces['oadr'] = "http://openadr.org/oadr-2.0b/2012/07"
3936
VERIFIER = XMLVerifier()
4037

4138
XML_SCHEMA_LOCATION = os.path.join(os.path.dirname(__file__), 'schema', 'oadr_20b.xsd')
@@ -122,6 +119,9 @@ def create_message(message_type, cert=None, key=None, passphrase=None, disable_s
122119
envelope = TEMPLATES.get_template('oadrPayload.xml')
123120
if cert and key and not disable_signature:
124121
tree = etree.fromstring(signed_object)
122+
SIGNER = XMLSigner(method=methods.detached,
123+
c14n_algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315")
124+
SIGNER.namespaces['oadr'] = "http://openadr.org/oadr-2.0b/2012/07"
125125
SIGNER.sign_alg = SignatureMethod.from_fragment(get_signature_algorithm_from_private_key(key))
126126
signature_tree = SIGNER.sign(tree,
127127
key=key,

0 commit comments

Comments
 (0)