Require client cert auth for gRPC, allow for JSON-RPC #1867
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Client authentication for JSON-RPC previously required configuring a
user and password, with both client and server holding knowledge of
the secret. By allowing client authentication to be performed with
TLS client certificates, only the client side must hold a private key,
as long as the dcrwallet server is configured to trust the public key.
The gRPC server had no client authentication at all previously, and
the only reason this was marginally safe was that all requests that
could use a wallet key also required supplying and checking the wallet
private passhprase in the request. However, with per-account
passphrases, this is no longer a suitable mechanism, and instead the
entire transport layer must be authenticated. The simplest way to
perform this is by requiring and verifying client certificates.
TLS client certificate authentication must be enabled with the
--authtype=clientcerts flag or config setting. The gRPC server will
no longer start without this setting, and enabling this also allows
the JSON-RPC server to be started without any user or password.
There are two ways in which a client certificate may be trusted:
A certificate authority is created which adds trust for a client
cert, or certs signed by the authority. This file defaults to
clients.pem in the dcrwallet application data directory and can
be modified to use other paths with the --clientcafile option.
Certificates can be created using gencerts, OpenSSL, and similar
tooling.
A parent process can read an issued ephemeral certificate and key
through a pipe. These certs and keys never reach the filesystem,
and this is the expected mechanism by which Decrediton will
authenticate itself to the gRPC server. This behavior is enabled
with the --issueclientcert flag.