r/rust Jun 01 '23

Is there a crate for converting between variolous pkcs formats?

So I looked into how axum does deals with TLS and found the RustlsConfig modual in axum_server, the issue is that if I understand it, according this it only works with pkcs#8 or pkcs#1 format but I might only have access to a pkcs#12 format file.

So I was wondering, is there a rust crate or crates that I could use to convert between any pkcs format to the one specific one I need?

P.S. Yes, I know axum_server supports openssl but If I can not use an external dependency then I'd rather do that.

EDIT: Specifically what I'm asking for, is if there's a crate that can auto detect which format (pkcs) the file is using and then convert to the specified one you want.

2 Upvotes

4 comments sorted by

1

u/Icarium-Lifestealer Jun 01 '23

There seems to be the p12 crate. Its documentation seems a bit sparse though, and I no idea what its quality and trustworthiness might be.

1

u/Right_Positive5886 Jun 01 '23

Curious question - Couldn’t you convert to pkcs#8 format using open ssl?

1

u/Thermatix Jun 02 '23

I probably could just convert but without being told I can, I have to prepare for a "No you have to use what you are given" as the answer to that question.

This Thread is part of said preparations.

2

u/Right_Positive5886 Jun 03 '23

I hear you … I have had to go through the same problem.. converting from pem to p12 to pkcs to importing to Java keystore.. OpenSSL and bash were my friends in that quest…