Last active
December 21, 2015 04:38
-
-
Save cvmat/6250555 to your computer and use it in GitHub Desktop.
An advice that enables url.el to connect a server with the HTTPS protocol via a HTTP proxy.
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
;; | |
;; If the OpenSSL executable is compiled with the patch in | |
;; http://rt.openssl.org/Ticket/Display.html?id=2651&user=guest&pass=guest , | |
;; the executable can connect a server via a HTTP proxy. | |
;; With the below code, the url.el library may connect a server with | |
;; the HTTPS protocol via a HTTP proxy. | |
;; | |
;; | |
;; Register a proxy for the "https" scheme from the environment | |
;; variable "https_proxy". | |
;; | |
(require 'url-methods nil t) | |
;; You can also specify the environment variable here as | |
;; (setenv "https_proxy" "http://proxy-host:proxy-port/") . | |
;; This `setenv' must precede the below call of `url-scheme-register-proxy'. | |
(url-scheme-register-proxy "https") | |
;; | |
;; Configure `tls-program' to use the proxy registered above. | |
;; | |
(let* ((proxy (cdr (assoc "https" url-proxy-services)))) | |
(when (and proxy | |
(string-match "^\\([^:]+\\):\\([0-9]+\\)$" proxy)) | |
(setq tls-program | |
`(,(concat "openssl s_client -connect %h:%p -no_ssl2 -ign_eof" | |
" -http_proxy " proxy) | |
,@tls-program)))) | |
(defadvice url-proxy (around https-proxy activate) | |
(cond | |
((string= (url-type url) "https") | |
(let ((url-using-proxy nil)) | |
(url-https url callback cbargs))) | |
(t | |
ad-do-it))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment