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

how to set the root certificate in pem format as a trust anchor #90

Open
narangmayank opened this issue Mar 2, 2023 · 12 comments
Open
Labels
question Further information is requested

Comments

@narangmayank
Copy link

I have the root certificate to verify the server identity in the below format, how to set this out.

const char root_ca[] =
"-----BEGIN CERTIFICATE-----\n"
"MIIDpDCCAowCCQC7mCk5Iu3YmDANBgkqhkiG9w0BAQUFADCBkzELMAkGA1UEBhMC\n"
...
"-----END CERTIFICATE-----\n";

I checked out the example codes but couldn't find the solution.

@narangmayank narangmayank added the question Further information is requested label Mar 2, 2023
@andersruneson
Copy link

I'm not sure I understand the question.

But you could use the tool below to generate the contents, that is the easiest way.
https://openslab-osu.github.io/bearssl-certificate-utility/

Then paste the output to the trust_anchors.h file in your project.

If you have a root cert in PEM format then you can use the tool below.
https://github.com/OPEnSLab-OSU/SSLClient/tree/master/tools/pycert_bearssl

$ python3 pycert_bearssl.py convert your_cert.pem

@narangmayank
Copy link
Author

narangmayank commented May 3, 2023

@andersruneson Thanks for coming up with this.

So my requirement is like root certificate (PEM format) will be stored in the file system partition (say spiffs) along with other broker information and during initialization phase I will read up the file system and connect to the broker. I can't change the format to be writing into file system in this case.

Please see our official sdk and let us know if there is any possibility for us to use the SSLClient library.

@andersruneson
Copy link

Ah, so want to convert a PEM-formatted root certificate on the device itself. That is not impossible, but you have to write some code yourself that converts a PEM-formatted certificate to the format used by bearssl, similar to the pycert_bearssl.py-tool. Unless you find a tool that does exactly this.

@narangmayank
Copy link
Author

can you add this as a feature for the library to be able to use certificate in the PEM format?

@andersruneson
Copy link

I'm just a user of this project, I don't have the skill to write that feature :)

@andersruneson
Copy link

andersruneson commented May 5, 2023

Well, I could probably do it if you pay me.
I came across this library which seems to have the cert in pem format: https://github.com/govorox/SSLClient

@cmdgeofease
Copy link

I'm not sure I understand the question.

But you could use the tool below to generate the contents, that is the easiest way. https://openslab-osu.github.io/bearssl-certificate-utility/

Then paste the output to the trust_anchors.h file in your project.

If you have a root cert in PEM format then you can use the tool below. https://github.com/OPEnSLab-OSU/SSLClient/tree/master/tools/pycert_bearssl

$ python3 pycert_bearssl.py convert your_cert.pem

Hello! For this tool you have above, do you know the expiry dates or duration of the certificates that it generates?

Thanks!

@andersruneson
Copy link

I think the tools just converts a cert to bear format, so the expiry is set when you generate the cert in the first place.

@cmdgeofease
Copy link

I think the tools just converts a cert to bear format, so the expiry is set when you generate the cert in the first place.

Thank you for the quick response. How about for the following tool? https://openslab-osu.github.io/bearssl-certificate-utility/

I created a trust anchor but am unsure the expiry date of it based on this tool.

thanks!

@andersruneson
Copy link

At the top of the page you select which domains it should pull certs for, so you can just open the domains you selected in chrome and check cert expiry.

@aremon78
Copy link

aremon78 commented Jun 8, 2024

thank you for this discussion, will try to convert ca to trust_anchor. do any of you know free mqtt broker that could generate ca, client key and client cert?

@aremon78
Copy link

aremon78 commented Jun 8, 2024

https://github.com/OPEnSLab-OSU/SSLClient/tree/master/tools/pycert_bearssl
try use this but always return Could not find a root certificate for certificate.crt
Wrote 0 trust anchors to certificates.h
any idea why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants