Skip to content

Encrypt/Decrypt not working (maybe wrong usage?) #13

@andreixk

Description

@andreixk

I created a simple xml file, generated a self-signed certificate and key:

openssl req -x509 -nodes -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365

then tried to encrypt it and then decrypt the encrypted data:

from wsse import encryption
plain = open('plain.xml','rb').read()
encr = encryption.encrypt(plain,'test/cert.pem')
print(encryption.decrypt(envelope=encr,keyfile='test/key.pem'))

The result is this error:

Traceback (most recent call last):
  File "/private/var/www/html/apps/moh/test.py", line 9, in <module>
    print(encryption.decrypt(envelope=encrd,keyfile='test/key.pem'))
  File "/private/var/www/html/apps/moh/wsse/encryption.py", line 196, in decrypt
    )[0]
IndexError: list index out of range

plain.xml:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://hcv.health.ontario.ca/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<SOAP-ENV:Header>
		<wsse:Security mustUnderstand="true">
			<wsse:UsernameToken>
				<wsse:Username>test_user</wsse:Username>
				<wsse:Password>test_pass</wsse:Password>
			</wsse:UsernameToken>
			<wsu:Timestamp>
				<wsu:Created>2017-07-18T01:32:47.577170+00:00</wsu:Created>
				<wsu:Expires>2017-07-18T01:34:17.577170+00:00</wsu:Expires>
			</wsu:Timestamp>
		</wsse:Security>
	</SOAP-ENV:Header>
	<ns0:Body>
		<ns1:validate>
			<requests>
				<hcvRequest>
					<healthNumber>9999999999</healthNumber>
					<versionCode>YX</versionCode>
				</hcvRequest>
			</requests>
			<locale>en</locale>
		</ns1:validate>
	</ns0:Body>
</SOAP-ENV:Envelope>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions