-
Notifications
You must be signed in to change notification settings - Fork 438
SignatureError at /saml2/login/ (failed to load external entity) #863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
hello, as with IdentityPython/pyXMLSecurity#71 it looks as if the process is not allowed to read files from temporary storage
Is the process allowed to read/write to the filesystem? |
@c00kiemon5ter it can write to the temp directory, as I can see the file is created but it can't open it for read, when I copy this file from temp dir to another dir I can open it, i tried to run as admin but still same problem |
ok, I think this goes back to the generic issue of the |
I can confirm that I have the same problem "SignatureError" when running djangosaml2 on Windows server 2016. I see two problems, a general problem is that installing xmlsec1.exe in windows is a bit complex as there are very few builds. The second problem is that the NamedTemporaryFile function only works in Windows when the temporary files are used by the current Python program and not when calling external programs such as xmlsec1.exe with Popen. This is due to file locks in Windows. Has anyone come up with a good solution to get this working under Windows? |
I am guessing everything should work within WSL2 (Windows Subsystem for Linux) |
WSL is not always an option, specifically for embedded python in windows applications. Until a solution is found, I have monkey patched the _run_xmlsec method to avoid the current issue: from saml2.sigver import CryptoBackendXmlSec1, XmlsecError, logger
from tempfile import NamedTemporaryFile
from subprocess import Popen
from subprocess import PIPE
def _run_xmlsec(self, com_list, extra_args):
"""
Common code to invoke xmlsec and parse the output.
:param com_list: Key-value parameter list for xmlsec
:param extra_args: Positional parameters to be appended after all
key-value parameters
:result: Whatever xmlsec wrote to an --output temporary file
"""
with NamedTemporaryFile(suffix='.xml', delete=False) as ntf:
com_list.extend(['--output', ntf.name])
com_list += extra_args
logger.debug('xmlsec command: %s', ' '.join(com_list))
pof = Popen(com_list, stderr=PIPE, stdout=PIPE)
p_out, p_err = pof.communicate()
p_out = p_out.decode()
p_err = p_err.decode()
if pof.returncode != 0:
errmsg = "returncode={code}\nerror={err}\noutput={out}".format(
code=pof.returncode, err=p_err, out=p_out
)
logger.error(errmsg)
raise XmlsecError(errmsg)
ntf.seek(0)
return p_out, p_err, ntf.read()
CryptoBackendXmlSec1._run_xmlsec = _run_xmlsec |
I'm using DjangoSaml2 on windows which use pysaml2, i download xmlsec1 and the needed dlls, below error is received when running
The text was updated successfully, but these errors were encountered: