git-lfs/lfshttp
brian m. carlson 706becaf20
lfsapi: add support for encrypted client TLS private keys
When using client certificates for TLS, it's possible to specify a
private key file with an encrypted private key.  Previously, we silently
returned a nil Certificate object in this case which promptly resulted
in a panic in crypto/tls when attempting to push.

Instead, let's detect that the key is encrypted and prompt for a
passphrase.  Git usually handles this with a prompt from OpenSSL, which
we aren't using, although it can be configured to use the credential
helper as well.

Since there isn't a portable way to turn off the echo in order to prompt
for a passphrase, even among Unix systems, let's use the credential
helper route for this purpose by prompting for credentials using a cert:
URL for the file holding the private key; this is the type of URL that
Git uses with the credential helper for this purpose.

In order to make things as intuitive as possible, tell the credential
code to always include the path for cert: URLs (so we don't just prompt
for "cert:///") and provide the user's current username in the username
field so they don't get a useless username prompt.  Provide as much
helpful trace output as possible for debugging; note that credential
filling success and failure already have trace logging enabled
elsewhere.

Note that we create our own credential helper for the client object to
avoid having to pass it into the HTTP client context from the LFS API
context; this should be fine, since we're going to prompt and use this
value only within this context and for this purpose.

Finally, since we're in a context where we can't really return an error
up the chain, if for whatever reason an error occurs, ensure that we
don't pass nil to crypto/tls and instead skip passing a certificate
altogether.  This will at least make the failure case obvious later on
and provide a better user experience than a panic.
2018-09-24 15:09:22 +00:00
..
body.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
certs_darwin.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
certs_freebsd.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
certs_linux.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
certs_openbsd.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
certs_test.go lfsapi: implement auth redirects 2018-09-11 14:51:29 -07:00
certs_windows.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
certs.go lfsapi: add support for encrypted client TLS private keys 2018-09-24 15:09:22 +00:00
client_test.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
client.go lfsapi: add support for encrypted client TLS private keys 2018-09-24 15:09:22 +00:00
endpoint.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
errors.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
lfshttp.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
proxy_test.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
proxy.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
retries_test.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
retries.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
ssh_test.go Merge branch 'master' into lfshttp 2018-09-14 11:42:19 -07:00
ssh.go subprocess: add functions to format shell commands 2018-09-14 22:31:39 +00:00
stats_test.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
stats.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
verbose_test.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
verbose.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00