BiagioFesta / wtransport

Async-friendly WebTransport implementation in Rust
Apache License 2.0
460 stars 31 forks source link

Derive Debug for Certificate #138

Closed cBournhonesque closed 7 months ago

cBournhonesque commented 9 months ago

This would be useful because I have a Certificate inside some structs that I would like to implement Debug for

TheButlah commented 8 months ago

I would like to second this, although I agree with @BiagioFesta that we should not reveal private keys in the process.

My use case is that I have other structs that I wish to derive(Debug) on, and therefore I need all types to implement Debug. I had to wrap it myself, which turned out to be a bit of a hassle. Its also useful for debuggers - many debuggers will use the Debug implementation to display the contents of the variable.

I actually think it might be wise to do this for almost every exported type. For example, I have similar problems with BiStream - it means that my types that hold a Framed don't implement Debug, and I had to write lots of boilerplate to wrap it.

cBournhonesque commented 8 months ago

Yes, my usecase is that I have some structs that I want to derive Debug on that contain a certificate. I guess a better solution is to have a custom Debug implementation.

BiagioFesta commented 8 months ago

I opened https://github.com/BiagioFesta/wtransport/pull/146

That PR has a bigger scope as it makes a refactoring of the TLS design module. However, it should also fix the Debug issue. The new main object, that is, Identity implements Debug without leaking the private key.

Lemme know if works for you. Thanks

BiagioFesta commented 8 months ago

I actually think it might be wise to do this for almost every exported type. For example, I have similar problems with BiStream - it means that my types that hold a Framed don't implement Debug, and I had to write lots of boilerplate to wrap it.

I completely agree. In general, it's totally ok to implement Debug for wtransport types. If some misses that, please open PR or an issue,

For BiStream: https://github.com/BiagioFesta/wtransport/commit/de61e40d86cdabd5c1da319e35303c03e7d77e99

BiagioFesta commented 7 months ago

I am going to close this PR as superseded by https://github.com/BiagioFesta/wtransport/pull/146

Debug is now provided for all TLS types without leaking private key