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.
Motivation
When using tonic with mtls, we expect the method
peer_certs
return PEM encoded certs sinceCertificate
is described as a PEM cert in the doc, but it actually returns a DER encoded certs.Solution
We could return the original
tokio_rustls::rustls::Certificate
withTlsStream::peer_certs
since theTlsStream
is import fromtokio_rustls
anyway.As for
Request::peer_certs
, we could encode the DER certs withpem
crate, so that it could be turned into atonic::transport::Certificate
properly. Now this method does more than justArc::clone
, so I removed theArc
in return value.I doubt that anyone would want a PEM encoded cert form peer, but seems like we've been trying to get rid of
rustls
types, and it's not worthy to change thetonic::transport::Certificate
to be compatible with DER for just this case.