incus icon indicating copy to clipboard operation
incus copied to clipboard

Add `get-client-certificate` and `get-client-token` functions to `incus remote`

Open stgraber opened this issue 10 months ago • 4 comments

Is there an existing issue for this?

  • [x] There is no existing issue for this feature

What are you currently unable to do

It's occasionally useful to be able to get the client certificate in order to send it to a remote server for trusting. So far we've had users directly look ~/.config/incus/client.crt, but having a dedicated command would be quite convenient, especially as it can internally kick in a certificate generation if one doesn't already exist.

Additionally, adding another command to get a client token (derived from the client certificate) would also be quite useful and would allow us to discontinue the current tls2jwt test tool in favor of a supported command.

What do you think would need to be added

No response

stgraber avatar Apr 27 '25 23:04 stgraber

Hello, I am a UT student working with a partner doing open source contributions for class credit, can my group be assigned this issue please? Thank you!

kevans1124 avatar Apr 28 '25 18:04 kevans1124

done!

stgraber avatar Apr 29 '25 00:04 stgraber

Hi! I’ve reviewed how tls2jwt.go works, i think it generates a JWT on demand using github.com/golang-jwt/jwt/v5, signed with the client certificate’s private key if my interpretation is right. This seems to align with the goal of the get-client-token command.

In tls2jwt.go, the jwt/v5 import is used freely, but that file is in the test/tools directory. What’s the correct way to use the same library in cmd/incus/remote.go? Should I import jwt/v5 directly like in the tool, or is there a preferred internal mechanism I should use instead?

stoven2k17 avatar May 05 '25 09:05 stoven2k17

Yep, you can import that one directly, that's fine.

It's already a dependency of Incus in general, both through the testing tool and through the server side logic.

stgraber avatar May 05 '25 19:05 stgraber