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

TLS setup #13

Merged
merged 3 commits into from
Jan 4, 2025
Merged

TLS setup #13

merged 3 commits into from
Jan 4, 2025

Conversation

ala-mode
Copy link
Collaborator

Different feature branch name, same code as #10 - closed because of issues migrating github repo from private to public which broke our forked personal github repos.

I'll also copy-paste the comments from #10 here.

@ala-mode ala-mode changed the base branch from main to dev December 22, 2024 21:24
@ala-mode
Copy link
Collaborator Author

ala-mode commented Dec 22, 2024

To generate self-signed keys, open /self_signed_certs/ in a terminal and use
openssl req -newkey rsa:4096 -x509 -sha512 -days 500 -nodes -out cert.pem -keyout key.pem

Running locally, a text-file is retrieved with a browser navigating to https://127.0.0.1:3953/getme and using wget --https-only --no-check-certificate https://127.0.0.1:3953/getme

No testing with nc to this point.

@ala-mode
Copy link
Collaborator Author

ala-mode commented Dec 22, 2024

to clarify the above cli invocation openssl req -newkey rsa:4096 -x509 -sha512 -days 500 -nodes -out cert.pem -keyout key.pem

req requests a keypair
-newkey rsa:4096 create an RSA key of 4096 bits
-x509 binds an identity to a public key using a digital signature, in this case it will be self-signed. at the prompts, the user can input any information they choose.
-sha512 specifies the message digest to sign the certificate
-days 500 specifies for how long the certificate is valid
-nodes we don’t want to encrypt the generated private key
-out cert.pem -keyout key.pem naming the certificate and the key that are outputted

@ala-mode
Copy link
Collaborator Author

Fixes #9.

@ala-mode
Copy link
Collaborator Author

you can also inspect the handshake of the TLS connecting with curl --insecure -vvI https://127.0.0.1:3953/getme 2>&1 while the server is running.

@ala-mode ala-mode added the draft label Dec 22, 2024
@ala-mode
Copy link
Collaborator Author

Latest commit is a merge commit, largely modified from previous dev branch with tracing.

Now, there is TLS support + tracing.

Tracing is not using tokio::net::TcpListener any longer, instead assigning the Router (app) a layer with TraceLayer::new_for_http().

also updated README.

using curl --insecure -vvI https://127.0.0.1:3953/getme 2>&1

I see:

* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: C=MN; ST=Outback; O=Zingolabs; OU=Autonomous Squad 0x1F`

on the client side, and

[timestamp] DEBUG request{method=HEAD uri=https://127.0.0.1:3953/getme version=HTTP/2.0}: tower_http::trace::on_request: started processing request
[timestamp] DEBUG request{method=HEAD uri=https://127.0.0.1:3953/getme version=HTTP/2.0}: tower_http::trace::on_response: finished processing request latency=0 ms status=200

on the server side.

@ala-mode ala-mode mentioned this pull request Dec 30, 2024
@ala-mode ala-mode removed the draft label Dec 31, 2024
Copy link
Contributor

@nachog00 nachog00 left a comment

Choose a reason for hiding this comment

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

I noticed that logs by tracing are spitting the whole app before logging the intended message.
I haven't pinpointed where that behavior comes from (might be tracing's default?).
It seems a bit cluttering to me, but I wouldn't block this PR on that anyways.

@ala-mode Do you agree on changing that or is there any big pro of having it that way that I'm missing? Maybe we would like to cap it to DEBUG level logs only?

Besides that, this PR seems fine to me.

@nachog00 nachog00 merged commit ae459c4 into zingolabs:dev Jan 4, 2025
@ala-mode
Copy link
Collaborator Author

ala-mode commented Jan 4, 2025

I noticed that logs by tracing are spitting the whole app before logging the intended message. I haven't pinpointed where that behavior comes from (might be tracing's default?). It seems a bit cluttering to me, but I wouldn't block this PR on that anyways.

@ala-mode Do you agree on changing that or is there any big pro of having it that way that I'm missing? Maybe we would like to cap it to DEBUG level logs only?

Besides that, this PR seems fine to me.

Thanks! I don't remember the particulars of the tracing. If we can find a way to streamline, I think that would be great. Because this has been merged, I suggest you open an issue with any details you know right now or fill find out, or just that it's a topic at all, so that we can remember to look into this.

@ala-mode ala-mode mentioned this pull request Jan 4, 2025
Closed
@nachog00 nachog00 mentioned this pull request Jan 5, 2025
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.

2 participants