Created
July 31, 2019 18:38
-
-
Save phmarek/d0ae810936b4f246fec8e2609d60604b to your computer and use it in GitHub Desktop.
Example for an SSL server plus a client, including client certificate. Needs the certs from my CL+SSL branch.
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
(in-package :cl-user) | |
(ql:quickload '(:hunchentoot :drakma)) | |
(hunchentoot:define-easy-handler (root :uri "/") | |
() | |
(let ((cert (hunchentoot:get-peer-ssl-certificate))) | |
(format nil "It works: ~a" | |
(unless (cffi:null-pointer-p cert) | |
(cl+ssl:certificate-subject-common-names cert))))) | |
(defvar *my-ssl-acceptor* (hunchentoot:start | |
(make-instance 'hunchentoot:easy-ssl-acceptor | |
:port 8001 | |
;:access-log-destination t | |
:ssl-privatekey-file (namestring "test/certs/test-key-no-password.key") | |
:ssl-certificate-file (namestring "test/certs/server+ca.crt")))) | |
;; Setup context for Hunchentoot | |
(setf cl+ssl::*ssl-global-context* | |
(cl+ssl:make-context :verify-mode cl+ssl:+ssl-verify-peer+ | |
:verify-location `(,(namestring "test/certs/ca.crt") | |
,(namestring "test/certs/CACertSigningAuthority.crt")) | |
)) | |
(drakma:http-request "https://localhost:8001/" | |
:force-ssl t | |
:key (namestring "test/certs/test-key-no-password.key") | |
:certificate (namestring "test/certs/client.crt") | |
:ca-file (namestring "test/certs/ca.crt")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment