hyperium / tonic

A native gRPC client & server implementation with async/await support.
https://docs.rs/tonic
MIT License
9.76k stars 997 forks source link

Certificate::from_pem does an unnecessary copy #1277

Open exFalso opened 1 year ago

exFalso commented 1 year ago

Version

0.8.3

Platform

no.

Crates

tonic

Description

This line https://github.com/hyperium/tonic/blob/555a8bcf422b6c32ccda78834ec781f8b6f0e564/tonic/src/transport/tls.rs#L21 does an unnecessary copy of the certificate, which in the case of multi-pem root stores may be large. Suggest adding a from_pem_vec-style function that takes ownership of a Vec<u8> instead.

exFalso commented 1 year ago

Same issue with tonic::transport::Identity

LucioFranco commented 1 year ago

We could add From<Vec<u8>> I would be ok with merging that

exFalso commented 1 year ago

Identity takes two Vecs, so added a separate function for that