yymax / x509test

A Python3 software that validates a client's side SSL/TLS application's X509 verification process
BSD 3-Clause "New" or "Revised" License
142 stars 21 forks source link

PyAsn1Error Empty substrate #4

Open floyd-fuh opened 9 years ago

floyd-fuh commented 9 years ago

Hi there,

I'm on OSX, installed dependencies via pip (via mac ports), python 3.3. For some reason the ASN1 parser seems to throw an Empty substrace error. Let me know if you need more debug info.

$ sudo python3.3 x509test.py www.tls.test -c full --ssl SSLv3 Starting SSL/TLS X509 Certificate Test Checking Root CA... Checking Test Directory... Building Functionality Test Cases... Building X509 Test Cases... Traceback (most recent call last): File "x509test.py", line 12, in Terminal().runTest() File "/opt/x509test/src/Terminal.py", line 246, in runTest cases = cases.build() File "/opt/x509test/src/TestSet.py", line 67, in build self.addTestCase(test, self.opt.replace) File "/opt/x509test/src/TestSet.py", line 310, in addTestCase testCase.testBuild(replace) File "/opt/x509test/src/Test.py", line 239, in testBuild self.procedure() File "/opt/x509test/src/Test.py", line 254, in procedure cert.build() File "/opt/x509test/src/Certificate.py", line 622, in build cert = self.asnModify(cert, self.modifier.preSign) File "/opt/x509test/src/Certificate.py", line 755, in asnModify cert = decoder.decode(substrate, asn1Spec=rfc2459.Certificate())[0] File "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyasn1/codec/ber/decoder.py", line 792, in call stGetValueDecoder, self, substrateFun File "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyasn1/codec/ber/decoder.py", line 321, in valueDecoder component, head = decodeFun(head, asn1Spec) File "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyasn1/codec/ber/decoder.py", line 792, in call stGetValueDecoder, self, substrateFun File "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyasn1/codec/ber/decoder.py", line 321, in valueDecoder component, head = decodeFun(head, asn1Spec) File "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyasn1/codec/ber/decoder.py", line 792, in call stGetValueDecoder, self, substrateFun File "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyasn1/codec/ber/decoder.py", line 321, in valueDecoder component, head = decodeFun(head, asn1Spec) File "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyasn1/codec/ber/decoder.py", line 792, in call stGetValueDecoder, self, substrateFun File "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyasn1/codec/ber/decoder.py", line 217, in valueDecoder raise error.PyAsn1Error('Empty substrate') pyasn1.error.PyAsn1Error: Empty substrate

cheers, floyd

yymax commented 9 years ago

I have ran the tool in OSX before so the OS itself should not be a problem. I did not install the modules using pip, however, so maybe that is the problem. Do you mind to download the modules (pyasn1 0.1.7 and pyasn1_modules 0.0.5) individually and install them manually (sudo python3.3 setup.py install)? Please let me know the result.

Thanks, Calvin

mnmnc commented 9 years ago

Just to let you know - I've tried to execute the script on Linux (Debian Jessie) and I've got exact same problem as floyd. To be honest I am using Python 3.4.2 so I suspect this might be a problem in my case.

yymax commented 9 years ago

Hmm... I just installed it using Python 3.4.0 on a (somewhat) fresh Ubuntu 64-bit VM and it works fine.

Here is my install process for all the dependencies: sudo su apt-get install build-essential libssl-dev libffi-dev python3-dev (I forgot whether I have already installed easy_install or other python module installation tools previously) [download pyOpenSSL tar file from https://pypi.python.org/pypi/pyOpenSSL, decompress] [download pyasn1 tar file from https://pypi.python.org/pypi/pyasn1, decompress] [download pyasn1-modules tar file from https://pypi.python.org/pypi/pyasn1-modules, decompress]

(cd into each python module downloaded, run) python3 setup.py install (pull the newest version of x509test, run) git https://github.com/yymax/x509test.git (execute the script, run) python3 x509test.py www.tls.test -c full --ssl SSLv3

Here is my output from the program: sudo python3 x509test.py www.tls.test -c full --ssl SSLv3 Starting SSL/TLS X509 Certificate Test Checking Root CA... Checking Test Directory... Building Functionality Test Cases... Building X509 Test Cases... Building Overflow Test Cases... Starting Network Server... Server Ready!

I am not sure what is the problem if not for the dependencies because I have ran the script on Ubuntu, Kali Linux, and OSX before and it did not crash like this...

Calvin

mnmnc commented 9 years ago

Ok. I've done exactly as you said and it finally worked. My system is Mint 17.1 @ kernel 3.13. During the installation of pyOpenSSL I had a problem indicated by error: error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1. To fix that I had to install:

sudo apt-get install libxml2-dev
sudo apt-get install libxslt1-dev

I found resolution here: http://stackoverflow.com/questions/26053982/error-setup-script-exited-with-error-command-x86-64-linux-gnu-gcc-failed-wit and here http://stackoverflow.com/questions/5178416/pip-install-lxml-error/5178444#5178444

Script now works fine. Thank you for your help.

carrotlqq commented 7 years ago

Hello! I'm on Ubuntu.I wanted to install x509test with python3.5.I installed pyOpenSSL 0.14 ,pyasn1 0.1.7 ,pyasn1_modules 0.0.5 and OpenSSL 1.0.2. But it can't work .I really need help!

$sudo python3 x509test.py www.tls.test -c full --ssl SSLv3 Starting SSL/TLS X509 Certificate Test Checking Root CA... Checking Test Directory... Building Functionality Test Cases... Traceback (most recent call last): File "x509test.py", line 12, in Terminal().runTest() File "/usr/bin/x509test/src/Terminal.py", line 246, in runTest cases = cases.build() File "/usr/bin/x509test/src/TestSet.py", line 61, in build self.addTestCase(test, self.opt.replace) File "/usr/bin/x509test/src/TestSet.py", line 310, in addTestCase testCase.testBuild(replace) File "/usr/bin/x509test/src/Test.py", line 239, in testBuild self.procedure() File "/usr/bin/x509test/src/Test.py", line 252, in procedure cert.signer.build() File "/usr/bin/x509test/src/Certificate.py", line 217, in build self.keyPassword) File "/usr/local/lib/python3.5/dist-packages/OpenSSL/crypto.py", line 2010, in load_privatekey _raise_current_error() File "/usr/local/lib/python3.5/dist-packages/OpenSSL/_util.py", line 22, in exception_from_error_queue raise exceptionType(errors) OpenSSL.crypto.Error: []