Created
March 29, 2013 12:49
-
-
Save lokedhs/5270622 to your computer and use it in GitHub Desktop.
How to get CN from an SSL connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(usocket:with-client-socket (socket stream "encrypted.google.com" 443) | |
(let* ((enc (cl+ssl:make-ssl-client-stream stream)) | |
(crypto (cl+ssl::ssl-stream-handle enc)) | |
(cert (cl+ssl::ssl-get-peer-certificate crypto)) | |
(subj (cl+ssl::x509-get-subject-name cert))) | |
(format t "entry count: ~s~%" (cl+ssl::x509-name-entry-count subj)) | |
(cffi:with-foreign-pointer (buf 10240) | |
(let ((result (cl+ssl::x509-name-get-text-by-nid subj 13 buf 10240))) | |
(if (= result -1) | |
(format t "Could not find nid~%") | |
(format t "Subject name: ~s~%" (cffi:foreign-string-to-lisp buf))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment