Skip to content

Commit a7ab990

Browse files
feat(wsse): add pure-Python WS-Security signing (no xmlsec dependency)
Add `zeep.wsse.crypto` module as a drop-in alternative to the existing xmlsec-based `zeep.wsse.signature` module. Uses the `cryptography` library instead of the C-based `xmlsec`, making installation straightforward on all platforms. New capabilities beyond the xmlsec-based module: - No C library dependency (pure Python via `cryptography` + `lxml`) - PKCS#12 (.p12/.pfx) key loading support - Configurable signed parts (Body, Timestamp, UsernameToken, BinarySecurityToken, or any element with wsu:Id) - Per-reference inclusive namespace prefixes for exclusive C14N - Mixed digest/signature algorithms (e.g. SHA-256 digests + RSA-SHA1) Classes: CryptoSignature, CryptoBinarySignature, CryptoMemorySignature, CryptoBinaryMemorySignature, PKCS12Signature Install with: pip install zeep[crypto] Closes mvantellingen#1357, relates to mvantellingen#1419, mvantellingen#1428, mvantellingen#1363, mvantellingen#1318 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c80519e commit a7ab990

7 files changed

Lines changed: 1451 additions & 3 deletions

File tree

setup.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
"xmlsec>=0.6.1",
2525
]
2626

27+
crypto_require = [
28+
"cryptography>=3.0",
29+
]
30+
2731
tests_require = [
2832
"coverage[toml]==5.2.1",
2933
"freezegun==0.3.15",
@@ -43,9 +47,7 @@
4347

4448

4549
with open("README.rst") as fh:
46-
long_description = re.sub(
47-
"^.. start-no-pypi.*^.. end-no-pypi", "", fh.read(), flags=re.M | re.S
48-
)
50+
long_description = re.sub("^.. start-no-pypi.*^.. end-no-pypi", "", fh.read(), flags=re.M | re.S)
4951

5052
setup(
5153
name="zeep",
@@ -66,6 +68,7 @@
6668
"test": tests_require,
6769
"async": async_require,
6870
"xmlsec": xmlsec_require,
71+
"crypto": crypto_require,
6972
},
7073
entry_points={},
7174
package_dir={"": "src"},

src/zeep/wsse/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,31 @@
22
from .signature import BinarySignature, MemorySignature, Signature
33
from .username import UsernameToken
44

5+
try:
6+
from .crypto import (
7+
CryptoBinaryMemorySignature,
8+
CryptoBinarySignature,
9+
CryptoMemorySignature,
10+
CryptoSignature,
11+
PKCS12Signature,
12+
)
13+
except ImportError:
14+
# cryptography not installed — pure-python signing unavailable
15+
CryptoBinaryMemorySignature = None
16+
CryptoBinarySignature = None
17+
CryptoMemorySignature = None
18+
CryptoSignature = None
19+
PKCS12Signature = None
20+
521
__all__ = [
622
"Compose",
723
"BinarySignature",
824
"MemorySignature",
925
"Signature",
1026
"UsernameToken",
27+
"CryptoBinaryMemorySignature",
28+
"CryptoBinarySignature",
29+
"CryptoMemorySignature",
30+
"CryptoSignature",
31+
"PKCS12Signature",
1132
]

0 commit comments

Comments
 (0)