首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在需要身份验证的代理后面使用ELPA (Emacs)

在需要身份验证的代理后面使用ELPA (Emacs)
EN

Stack Overflow用户
提问于 2012-05-28 15:32:08
回答 3查看 17.1K关注 0票数 24

我读过thisthis的问题。在这两种情况下,他们都说Emacs可以处理身份验证,但对我不起作用。

问题是:出了什么问题?

Emacs版本为24.0.97-1,它运行在64位Linux上.

在工作中,我必须使用代理服务器的任何互联网连接。因此,我设置了以下环境变量:

代码语言:javascript
复制
http_proxy="http://username:password@ip:port"
https_proxy="https://username:password@ip:port"
ftp_proxy="ftp://username:password@ip:port"

这是可行的,我可以下载没有任何问题的软件包。

在Emacs中运行M-x package-refresh-contents时,它向我询问代理服务器的登录和密码,但它无法连接到服务器。它甚至不尝试连接,即在我输入密码并按Enter Emacs 立即 reports:Failed to download 'marmalade' archive之后。

如果我从http_proxy变量中删除用户名和密码,或者在Emacs中设置url-proxy-services (即使我取消设置系统变量),也会发生同样的情况。

EN

回答 3

Stack Overflow用户

发布于 2013-09-09 11:27:54

Emacs只使用HOST和来自http_proxyPORT部件。

我通过以下方式获得授权,而无需用户交互:

代码语言:javascript
复制
(setq url-proxy-services
   '(("no_proxy" . "^\\(localhost\\|10.*\\)")
     ("http" . "proxy.com:8080")
     ("https" . "proxy.com:8080")))

(setq url-http-proxy-basic-auth-storage
    (list (list "proxy.com:8080"
                (cons "Input your LDAP UID !"
                      (base64-encode-string "LOGIN:PASSWORD")))))

这适用于Emacs 24.3。它是基于非公开的API技巧,所以可能无法工作的另一个Emacs版本.

用你的信息代替LOGINPASSWORD .

还有url-http-proxy-digest-auth-storage。只需用身份验证数据填充提示并检查Emacs ( M-: var RET)使用的var .

票数 19
EN

Stack Overflow用户

发布于 2012-06-14 07:03:32

看起来Emacs在身份验证方面有一些问题。因此,我已经安装了Squid,现在将它用作外部代理服务器和所有应用程序之间的中间层。Squid在没有身份验证的情况下被配置为代理,并且一切都运行良好。

许多人推荐这个解决方案,但没有给出精确的指示。我的/etc/squid/squid.conf是从另一个为不同目的而设计的。可能它包含了一些不需要的东西和/或错过了它应该拥有的东西。欢迎作出任何改进:

代码语言:javascript
复制
# only access from localhost is allowed
acl localhost src 127.0.0.1/32
acl all src all
http_access allow localhost
http_access deny all
icp_access deny all

never_direct allow all

# turn off cache
cache_dir null /tmp
cache deny all

# logs
access_log /var/log/squid/access.log squid

# turn off proxy-headers (no idea what is it :))
via off
forwarded_for off

# describe external proxy server
cache_peer <proxy_ip> parent <proxy_port> 0 no-query default proxy-only login=<my_login>:<my_password>
http_port 10000
acl port10000 myport 10000
cache_peer_access <proxy_ip> allow port10000

此代理具有地址127.0.0.1:10000。在Emacs中,我必须执行以下代码:

代码语言:javascript
复制
(setq url-proxy-services '(("http" . "127.0.0.1:10000")))
票数 7
EN

Stack Overflow用户

发布于 2020-11-06 23:02:37

url-http中的emacs < 28.1中还有另一个与url-https-proxy-connect函数相关的错误,导致通过身份验证代理进行的所有https调用都失败。

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=42422

作为emacs < 28.1的解决办法,用固定版本覆盖函数:

代码语言:javascript
复制
(with-eval-after-load 'url-http
  (defun url-https-proxy-connect (connection)
    (setq url-http-after-change-function 'url-https-proxy-after-change-function)
    (process-send-string connection (format (concat "CONNECT %s:%d HTTP/1.1\r\n"
                            "Host: %s\r\n"
                            (let ((proxy-auth (let ((url-basic-auth-storage
                                         'url-http-proxy-basic-auth-storage))
                                    (url-get-authentication url-http-proxy nil 'any nil))))
                              (if proxy-auth (concat "Proxy-Authorization: " proxy-auth "\r\n")))
                            "\r\n")
                        (url-host url-current-object)
                        (or (url-port url-current-object)
                        url-https-default-port)
                        (url-host url-current-object)))))
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10787087

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档