-
Notifications
You must be signed in to change notification settings - Fork 1
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
Enable TLS Configuration with in-memory PEM strings #2
Comments
One additional thing, I forgot about the load_verify_locations_from_file. This can also be turned into an in-memory thing. Which should then be part of the above That would extend it to something like:
But one thing though... it may be a good idea to make it optional. With That way if it's not provided, then quiche will do the default. I'm not entirely sure if the default is just that it does nothing. Tests should indicate whether it does actually automatically read the OS's cert store. I suspect not, and that it would be an application concern. This feeds into the rotation issue #3, since it would also be possible to rotate the However application-wise we wouldn't be using |
I have it working now, at least, it compiles and runs in the tests. The |
Were they timing out before the change? I was working on artificially testing if the server did not exist. So timing out was actually what I wanted. If you want it to not timeout. You should renable the server. Remember I was experimenting with the dialling phase so I didn't want a server to exist. I don't think I uncommented out my experiments. Check the code of the quic client tests. |
I can bring in a bunch of stuff from I'll also bring in the fast check stuff. |
Trying to generate the TLS configs is blowing out the dependencies and scope of this issue. I think I should branch that part off and address it in a separate issue. Hard coding the pems for tests is functional for now. |
You only need 1 thing to generate TLS certs. The You can generate keys using regular Node's webcrypto. |
Node actually has a x509 built in too, but I reckon it's better to just use the And no you don't need to bring all the types, just do the most simplest possible certificate and certificate chain tests. You should test that a cert chain also works too. |
Would be good to however generate ed25519 keys for the certs, because those are the keys we use for our x509 certs in PK. The latest version of node does support ed25519 keys. |
Due to this PeculiarVentures/webcrypto#55, see |
I went back to a previous commit to see if the I'll close this issue with a commit message, I don't think there is a need for a PR. |
This issue will auto close when the commit hits the main branch. Do you want to look over the changes? |
They were timing out because there's no server. Just re-enable the server. |
Changing the test to: test('times out when there is no server', async () => {
// QUICClient repeatedly dials until the connection timesout
await expect(QUICClient.createQUICClient({
host: '127.0.0.1' as Host,
port: 55555 as Port,
localHost: '127.0.0.1' as Host,
crypto,
logger: logger.getChild(QUICClient.name),
config: {
maxIdleTimeout: 1000,
}
})).rejects.toThrow(errors.ErrorQUICConnectionTimeout);
}); Then re-running everything works.
|
Specification
In QUIC our current system requires passing a file path into
QUICConfig
.These 2 properties are required on the server side, while they are optional on the client side. PK will of course use these 2 on both client and server.
These 2 properties are later used by
config.buildQuicheConfig
:It's better to be able to pass PEM strings, then require the QUIC client and QUIC server to read certificates and keys from the local filesystem. It's more secure as we don't leave any secrets on the local filesystem.
In order to do this, we need to add a new factory method to the
config.rs
.The body of this function will need to take the PEM strings bridged by napi-rs, and then use the
boring
package to turn them into thex509
objects.Subsequently use
boring::ssl::SslContext::builder
to create a SSL context builder, which then takes those objects and builds the SSL context.Finally it should be possible to use
quiche::Config::with_boring_ssl_ctx
to finally build a config object with string cert and key.Currently in PK, we have the types:
Both are string types. These will be used when we want to load certs and key into the QUIC connection.
Tests should test the usage of this on both client and server, with the
verifyPeer
option set to true.Tests should ensure that certificate chains are also accepted. The cert chain PEM doesn't just mean 1 certificate, it could have a whole chain of certificates.
An additional problem is dealing with certificate and key rotation. I'll address this in a separate issue.
Additional context
dgram
module #1 (comment) - How to create a local TLS certificate and key usingstep
CLI program.Tasks
boring
package intoCargo.toml
.shell.nix
withrustPlatform.bindgenHook
so thatboring
can actually compileconfig.rs
with thewith_boring_ssl_ctx
method. Use chat gpt and github copilot to help you find out what kind of code to write.npm run napi-build
.src/native/types.ts
buildQuicheConfig
to take the TLS cert pem and key pem strings.localhost.key
andlocalhost.crt
, but instead synthetically generate these 2 in-memory now. You can use peculiar's x509 library as adevDependency
and follow the PK'ssrc/keys/utils/x509.ts
to understand how to generate a relevant certificate chain for testing purposes.localhost.crt
andlocalhost.key
first as strings. But it's better we can use fastcheck to generate different kinds of certs for testing.The text was updated successfully, but these errors were encountered: