Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

example: how to validate a certificate

  • Loading branch information...
commit 7637a4ce32d3e97cbb179ac01d2a6f39641f89f6 1 parent e28c6a3
@abbot authored
Showing with 13 additions and 0 deletions.
  1. +13 −0 examples/validate_certificate.py
View
13 examples/validate_certificate.py
@@ -0,0 +1,13 @@
+import sys
+
+from m2ext import SSL
+from M2Crypto import X509
+
+print "Validating certificate %s using CApath %s" % (sys.argv[1], sys.argv[2])
+cert = X509.load_cert(sys.argv[1])
+ctx = SSL.Context()
+ctx.load_verify_locations(capath=sys.argv[2])
+if ctx.validate_certificate(cert):
+ print "valid"
+else:
+ print "invalid"
Please sign in to comment.
Something went wrong with that request. Please try again.