Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add AutoTLS example #3103

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft

feat: add AutoTLS example #3103

wants to merge 14 commits into from

Conversation

2color
Copy link
Contributor

@2color 2color commented Dec 17, 2024

This adds an example showing how to use the p2p-forge client library with the AutoTLS backend to issue a wild card certificate.

Credits to @guillaumemichel for writing the initial code in this example.

Fix before merging

  • The libp2p.direct address is not announced by the peer via identify, even though the peer has successfully minted a TLS certificate

examples/autotls/README.md Outdated Show resolved Hide resolved
@2color
Copy link
Contributor Author

2color commented Dec 19, 2024

@MarcoPolo Is it a problem this PR upgrades the go to 1.23 in go.mod?

I believe this happened due to dependency on p2p-forge

@2color 2color mentioned this pull request Dec 20, 2024
2 tasks
@2color 2color requested a review from lidel January 8, 2025 09:53
@guillaumemichel
Copy link
Contributor

ipshipyard/p2p-forge#29 should solve the build issue

@2color
Copy link
Contributor Author

2color commented Jan 8, 2025

When running this, occasionally it doesn't retrieve (or even request). Here are logs

this also passes correct logger so debug messages from
p2p-forge/client are printed correctly
Comment on lines +46 to +52
// Configure CA ACME endpoint
// NOTE:
// This example uses Let's Encrypt staging CA (p2pforge.DefaultCATestEndpoint)
// which will not work correctly in browser, but is useful for initial testing.
// Production should use Let's Encrypt production CA (p2pforge.DefaultCAEndpoint).
p2pforge.WithCAEndpoint(p2pforge.DefaultCATestEndpoint), // test CA endpoint
// TODO: p2pforge.WithCAEndpoint(p2pforge.DefaultCAEndpoint), // production CA endpoint
Copy link
Member

@lidel lidel Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@2color would appreciate sanity check on this.

My "strong conviction held weakly" is that we should be good citizens for LE and not use production endpoints in examples like this.

For now, I switched this code to use staging endpoint Let's Encrypt provided for the purpose of testing and examples – https://letsencrypt.org/docs/staging-environment/.

But since libp2p.direct is on https://publicsuffix.org/ we don't really care about rate-limiting, mostly just dont want to pollute https://crt.sh/?q=libp2p.direct with noise produced by this example.

At the same time, perhaps its a lesser evil to use production endpoint in example – if people copy&paste blindly, they will get broken certs and unless they try to connect to WSS in browser, they will not know its broken.

So the question is: should we switch this example back to production one? (p2pforge.DefaultCATestEndpointp2pforge.DefaultCAEndpoint)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I wasted a fair while trying to figure out what was wrong after I had deliberately switched to the staging env. I think we just need to log conspicuously when using staging.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good idea.

I will add the same "ERROR" log to p2p-forge/client when staging/testing endpoint is used to make sure folks remember to change it and it never sneaks into production.

This way we dont pollute this example, and everyone using client will benefit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lidel lidel marked this pull request as draft January 8, 2025 18:07
Comment on lines +3 to +5
go 1.23

toolchain go1.22.3
toolchain go1.23.3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 I suspect this produces staticcheck ./... error:

In the past, the fix was to:

  1. check if go install honnef.co/go/tools/cmd/staticcheck@lateststaticcheck ./... passes locally
  2. ask IPDX to update Unified GO CI to use new staticcheck

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed, staticcheck@a093f7c2d3d45d5104fb3414ae939a98be37be02 used on CI does not support 1.23 correctly, and 1.22 is also bit out of date: https://github.com/dominikh/go-tools/releases

Will ping IPDX.

lidel added a commit to ipshipyard/p2p-forge that referenced this pull request Jan 8, 2025
this implements idea from
libp2p/go-libp2p#3103 (comment)
to ensure users who set up staging endpoint for testing
are always aware fo it and never ship it to production
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants