diff -r 0f1311e829c9 -r 0593e8f81c71 mercurial/url.py --- a/mercurial/url.py Fri Aug 05 21:05:40 2011 +0200 +++ b/mercurial/url.py Fri Aug 05 21:05:41 2011 +0200 @@ -26,7 +26,7 @@ return (user, passwd) if not user or not passwd: - res = httpconnectionmod.readauthforuri(self.ui, authuri) + res = httpconnectionmod.readauthforuri(self.ui, authuri, user) if res: group, auth = res user, passwd = auth.get('username'), auth.get('password') @@ -53,6 +53,10 @@ msg = _('http auth: user %s, password %s\n') self.ui.debug(msg % (user, passwd and '*' * len(passwd) or 'not set')) + def find_stored_password(self, authuri): + return urllib2.HTTPPasswordMgrWithDefaultRealm.find_user_password( + self, None, authuri) + class proxyhandler(urllib2.ProxyHandler): def __init__(self, ui): proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy') @@ -342,7 +346,11 @@ return keepalive.KeepAliveHandler._start_transaction(self, h, req) def https_open(self, req): - res = httpconnectionmod.readauthforuri(self.ui, req.get_full_url()) + # req.get_full_url() does not contain credentials and we may + # need them to match the certificates. + url = req.get_full_url() + user, password = self.pwmgr.find_stored_password(url) + res = httpconnectionmod.readauthforuri(self.ui, url, user) if res: group, auth = res self.auth = auth