on 2021-02-24 01:05 PM
The JRE, Java Runtime Environment, bundled with STM32CubeIDE only contains public certificate authorities (CA). Sometimes, you need to add a private CA, for example when using a proxy server to access the Internet.
The following problem may appear in STM32CubeIDE if the CA is not included in the truststore:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Import CA certificate into current version of JRE’s truststore.
Pros: keep public CA certificates always up to date
Cons: each time there is a JRE update, the private CA certificates needs to be re-imported
1. Close STM32CubeIDE 2. Open STM32CubeIDE installation folder 3. Open <stm32cubeide.ini> and locate the current JRE in the file, Example: -vm plugins/com.st.stm32cube.ide.jre.linux64_x.x.x.xxxxx/jre/bin4. Import the CA certificate with keytool
$ cd plugins/com.st.stm32cube.ide.jre.linux64_x.x.x.xxxxx/jre
$ bin/keytool -importcert -alias aUniqueName -keystore lib/security/cacerts -file thePathToTheCaToImport.cer
Default truststore password is “changeit” and needs to be left as this
5. Redo step 4 for every required CA certificate
Duplicate certificate from current version of JRE’s truststore.
Pros: configuration persisted across STM32CubeIDE JRE updates
Cons: public CA certificates that have been revoked will remain trusted in STM32CubeIDE
1. Close STM32CubeIDE
2. Open STM32CubeIDE installation folder
3. Open <stm32cubeide.ini> and locate the current JRE in the file, Example:
-vm
plugins/com.st.stm32cube.ide.jre.linux64_x.x.x.xxxxx/jre/bin
4. Copy the current truststore
$ cp plugins/com.st.stm32cube.ide.jre.linux64_x.x.x.xxxxx/jre/lib/security/cacerts /somewhere/cacerts
5. Import the CA certificate with keytool
$ cd plugins/com.st.stm32cube.ide.jre.linux64_x.x.x.xxxxx/jre
$ bin/keytool -importcert -alias aUniqueName -keystore /somewhere/cacerts -file thePathToTheCaToImport.cer
Default truststore password is “changeit” and needs to be left as this
6. Redo step 5 for every required CA certificate
7. Add these lines at the end of <stm32cubeide.ini>
-Djavax.net.ssl.trustStore=/somewhere/cacerts
-Djavax.net.ssl.trustStorePassword=changeit