Skip to content

Commit d88dcc8

Browse files
authored
Merge pull request #1 from ener-i/xmlsec-1_3-compat
Xmlsec 1 3 compat
2 parents 1563947 + 40c14c4 commit d88dcc8

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ repos:
3131
exclude: ^setup.py$
3232
additional_dependencies: [flake8-docstrings, flake8-bugbear, flake8-logging-format, flake8-builtins, flake8-eradicate, flake8-fixme, pep8-naming, flake8-pep3101, flake8-annotations-complexity,flake8-pyi]
3333
- repo: https://github.com/PyCQA/isort
34-
rev: 5.10.1
34+
rev: 5.12.0
3535
hooks:
3636
- id: isort
3737
- repo: https://github.com/pre-commit/mirrors-mypy

doc/source/modules/constants.rst

-6
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,6 @@ Namespaces
166166
.. data:: xmlsec.constants.XPointerNs
167167
:annotation: = 'http://www.w3.org/2001/04/xmldsig-more/xptr'
168168

169-
.. data:: xmlsec.constants.Soap11Ns
170-
:annotation: = 'http://schemas.xmlsoap.org/soap/envelope/'
171-
172-
.. data:: xmlsec.constants.Soap12Ns
173-
:annotation: = 'http://www.w3.org/2002/06/soap-envelope'
174-
175169
.. data:: xmlsec.constants.NsExcC14N
176170
:annotation: = 'http://www.w3.org/2001/10/xml-exc-c14n#'
177171

src/constants.c

-2
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,6 @@ int PyXmlSec_ConstantsModule_Init(PyObject* package) {
316316
PYXMLSEC_ADD_NS_CONSTANT(XPathNs, "XPATH");
317317
PYXMLSEC_ADD_NS_CONSTANT(XPath2Ns, "XPATH2");
318318
PYXMLSEC_ADD_NS_CONSTANT(XPointerNs, "XPOINTER");
319-
PYXMLSEC_ADD_NS_CONSTANT(Soap11Ns, "SOAP11");
320-
PYXMLSEC_ADD_NS_CONSTANT(Soap12Ns, "SOAP12");
321319
PYXMLSEC_ADD_NS_CONSTANT(NsExcC14N, "EXC_C14N");
322320
PYXMLSEC_ADD_NS_CONSTANT(NsExcC14NWithComments, "EXC_C14N_WITH_COMMENT");
323321

src/enc.c

+12
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
#include <xmlsec/xmlenc.h>
1818
#include <xmlsec/xmltree.h>
1919

20+
// Backwards compatibility with xmlsec 1.2
21+
#ifndef XMLSEC_KEYINFO_FLAGS_LAX_KEY_SEARCH
22+
#define XMLSEC_KEYINFO_FLAGS_LAX_KEY_SEARCH 0x00008000
23+
#endif
24+
2025
typedef struct {
2126
PyObject_HEAD
2227
xmlSecEncCtxPtr handle;
@@ -50,6 +55,13 @@ static int PyXmlSec_EncryptionContext__init__(PyObject* self, PyObject* args, Py
5055
}
5156
ctx->manager = manager;
5257
PYXMLSEC_DEBUGF("%p: init enc context - ok, manager - %p", self, manager);
58+
59+
// xmlsec 1.3 changed the key search to strict mode, causing various examples
60+
// in the docs to fail. For backwards compatibility, this changes it back to
61+
// lax mode for now.
62+
ctx->handle->keyInfoReadCtx.flags = XMLSEC_KEYINFO_FLAGS_LAX_KEY_SEARCH;
63+
ctx->handle->keyInfoWriteCtx.flags = XMLSEC_KEYINFO_FLAGS_LAX_KEY_SEARCH;
64+
5365
return 0;
5466
ON_FAIL:
5567
PYXMLSEC_DEBUGF("%p: init enc context - failed", self);

src/xmlsec/constants.pyi

-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ NodeX509Data: Final[str]
8585
Ns: Final[str]
8686
NsExcC14N: Final[str]
8787
NsExcC14NWithComments: Final[str]
88-
Soap11Ns: Final[str]
89-
Soap12Ns: Final[str]
9088
TransformAes128Cbc: Final[__Transform]
9189
TransformAes128Gcm: Final[__Transform]
9290
TransformAes192Cbc: Final[__Transform]

0 commit comments

Comments
 (0)