mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 03:05:51 +03:00
[GH-ISSUE #618] Try to avoid cloning Rustls ClientConfig on creating TlsStreams #251
Labels
No labels
blocked
breaking-change
bug
bug:critical
bug:tests
cleanup
compliance
compliance
compliance
crate:all
crate:client
crate:native-tls
crate:proto
crate:recursor
crate:resolver
crate:resolver
crate:rustls
crate:server
crate:util
dependencies
docs
duplicate
easy
easy
enhance
enhance
enhance
feature:dns-over-https
feature:dns-over-quic
feature:dns-over-tls
feature:dnsssec
feature:global_lb
feature:mdns
feature:tsig
features:edns
has workaround
ops
perf
platform:WASM
platform:android
platform:fuchsia
platform:linux
platform:macos
platform:windows
pull-request
question
test
tools
tools
trust
unclear
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hickory-dns#251
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sticnarf on GitHub (Nov 16, 2018).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/618
Is your feature request related to a problem? Please describe.
There are two ways of adding CAs if I use DNS over Rustls:
add_cafunctionThe problem is that if I want to create
TlsStreams repeatly with the same CAs, I can come up with no way to avoid cloning the ClientConfig or adding the CAs every time I build a TlsStream.Describe the solution you'd like
The essence of the problem is that TlsStreamBuilder owns ClientConfig and the
buildfunction consumes the TlsStreamBuilder. There are approaches, but they break the API and I cannot decide which one is better.One approach is letting TlsStreamBuilder give up the ownership of ClientConfig. TlsStreamBuilder can own an
Arc<ClientConfig>but will have to remove theadd_cafunction.Another one is preventing the
buildfunction from consuming the builder and still retain theadd_cafunction. This might introduce more work. Theadd_cafunction modifies theClientConfig, but it is possible that the config is made into an Arc and passed out. So, afterbuildis called, callingadd_caimplies a clone to the ClientConfig. However, it is unacceptable that every time adding a CA clones the config. So we must remember ifbuildis called. It looks ugly but brings less API breakage.Of course, I am happy to see if there is a better solution.
@bluejekyll commented on GitHub (Nov 17, 2018):
I’m on a trip, so I can’t look at the code right now. But based on your observations, probably changing to
Arcin the builder would be fine.On removing the
ad_camethod on the builder, the reason this is there is to have a more consistent interface with how OpenSSL is supported. I’m not sure how important that is, and have been considering dropping OpenSSL support all together.I’m open to either option. One thing that I’d like to understand, this is just to be able to reuse the same
ClientConfig, right? And not to change it in between usage, as that would require a clone anyway I believe.@sticnarf commented on GitHub (Nov 18, 2018):
Exactly. I think it is a common case that we do resolving more than once. Lots of
TlsStreams are opened, and we rarely change the CA list.I took a look at the code in the resolver crate. It just adds all CAs every time before a connection is established. It feels bad to me if we need to do a lot of resolving...
By the way, I do not think we can actually drop OpenSSL support. Rustls depends on ring, which is currently not very portable. For example, ring does not support mips architecture yet.
@bluejekyll commented on GitHub (Nov 18, 2018):
I agree with the reason to do this. If you’re comfortable submitting a PR, That would be great.
As to mips, I’m unaware of anyone using this with mips, and don’t know if that’s possible with the current library. Theoretically it is a valuable reason to support OpenSSL, among others.
I was just giving background on these design decisions.
lookup_ipshould checkout/etc/hosts/before dns requests? #387