M2Crypto: X509.X509_Extension_Stack() throws AssertionError

Matthias Güntert MatzeGuentert at gmx.de
Mon Aug 3 04:46:29 EDT 2009


Hello python-list members

Why is the following code snippet throwing an AssertionError? Is that
behavior a bug within X509.X509_Extension_Stack()? How would you suggest
popping every element from the stack?

Regards,
Matthias Güntert 

-------------------------------------------------
from M2Crypto import X509

if __name__ == '__main__':
    cert_extension_stack = X509.X509_Extension_Stack()
    
    cert_extension_1 = X509.new_extension("basicConstraints",
"CA:FALSE")
    cert_extension_1.set_critical()
    
    cert_extension_2 = X509.new_extension("keyUsage", "101000000") 
    cert_extension_2.set_critical()
    
    cert_extension_3 = X509.new_extension("subjectAlternativeName",
"DNS:www.mydomain.tld")
    
    print cert_extension_stack.push(cert_extension_1)
    print cert_extension_stack.push(cert_extension_2)
    print cert_extension_stack.push(cert_extension_3)
    
    print cert_extension_stack.pop()
-------------------------------------------------

-------------------------------------------------
Traceback (most recent call last):
  File "test.py", line 18, in <module>
    print cert_extension_stack.pop()
  File "/usr/lib64/python2.6/site-packages/M2Crypto/X509.py", line 159,
in pop
    assert len(self.pystack) == 0
AssertionError
1
2
3
-------------------------------------------------




More information about the Python-list mailing list