* chore: Add tags to .gitignore
When generating ctags/universal-ctags, a 'tags' file is generated. This
commit adds any generted 'tags' file to .gitignore.
* feat(build): Expose type_attribute and field_attribute
This commit exposes the `type_attribute` and `field_attribute`
configuration settings from Prost. These are useful to tweak/extend the
generated types.
For example:
```
tonic_build::configure()
.out_dir(tmp)
.format(false)
.type_attribute(".", "#[derive(Serialize, Deserialize)]")
.type_attribute(".", "#[serde(rename_all = \"camelCase\")]")
.field_attribute("in", "#[serde(rename = \"in\")]")
.compile(&["tests/protos/wellknown.proto"], &["tests/protos"])
.unwrap();
```
Would add the serde `Serialize` and `Deserialize` traits, while renaming
all the fields to camelCase, and having serde keep fields named `in`
named `in`, rather than Prost's `in_`, to every type generated by Prost.
This commit reworks TLS configuration of both servers and endpoints in
order to provide a more flexible API. We now add options to configure
the selected TLS library using the appropriate 'native' configuration
structures, as well as retaining the existing simplier interface which
is compatible with both.
The new API can also be easily extended to support simple interfaces for
configuring mTLS and a range of other options without creating sprawl
in the builders for `Server` and `Endpoint`.
* transport: no crash after bad TLS handshake
Prevents the server exiting after a bad TLS handshake / error during
accept(). Instead the connection is dropped and the server continues to
serve new clients.
Previously an error would bubble up from the TLS library (tested with
rustls) and cause hyper to exit with:
[src/main.rs:85] &e = Error(
Server,
Error(
Accept,
Custom {
kind: InvalidData,
error: CorruptMessage,
},
),
)
* transport: add tracing error for TLS handshake failure
Co-Authored-By: Lucio Franco <luciofranco14@gmail.com>
* fix(codec): Fix buffer decode panic on full
This is a naive fix for the buffer growing beyond capacity
and producing a panic. Ideally we should do a better job
of not having to allocate for new messages by using
a link list.
* fmt
Currently, using an RSA key - or indeed any text which is not a
PEM-encoded PKCS8-format key with RusTLS panics with an index-out-of-
range exception.
This commit introduces two new types of `TlsError` which indicate
problems with loading a certificate or private key:
- `CertificateParseError`, indicating that the certificate cannot be
parsed
- `PrivateKeyParseError`, indicating that the private key cannot be
parsed.
Additionally, in the case that reading the private key as PKCS8 fails,
we now try loading it as an RSA key before failing.