Skip to content

Instantly share code, notes, and snippets.

@senior
Last active August 29, 2015 14:26
Show Gist options
  • Save senior/e454573cc2cc5b5bfca2 to your computer and use it in GitHub Desktop.
Save senior/e454573cc2cc5b5bfca2 to your computer and use it in GitHub Desktop.
mutually authenticated connection code
(define (ssl-conn-factory ca-cert-path cert-path key-path)
(lambda (uri-host uri-port)
(let ((ssl-ctx (ssl-make-client-context 'tls)))
(ssl-load-certificate-chain! ssl-ctx cert-path)
(ssl-load-private-key! ssl-ctx key-path)
(ssl-load-suggested-certificate-authorities! ssl-ctx ca-cert-path)
(ssl-load-verify-root-certificates! ssl-ctx ca-cert-path)
(ssl-set-verify! ssl-ctx #t)
(ssl-connect uri-host
uri-port
ssl-ctx))))
;;...
(make-request uri: uri
conn-factory: (ssl-conn-factory (hash-table-ref conn-info 'ca)
(hash-table-ref conn-info 'cert)
(hash-table-ref conn-info 'key))
method: 'GET)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment