MATLAB Answers

Managing Public Key Certificates in Matlab

83 views (last 30 days)
Jim Hokanson
Jim Hokanson on 27 May 2012
Commented: Chris Clarke on 27 Jan 2020 at 16:59
Hi all,
I recently tried to request a secure web page via https and got a Java error when trying to validate a certificate, something about not being able to find a trusted chain. I already have a hard time understanding certificates and now I have to deal with them in Matlab. I think I found a solution to my problem but I have a very minimal idea as to what I did and would love to have someone offer a solution that was nice and simple as opposed to my somewhat kludgy solution that makes me want to throw things.
Formally speaking, the question is how to handle non-trusted certificates in Matlab. This includes everything from my long standing question of, how do I know I can trust them to making it so that Matlab trusts them as well.


Sign in to comment.

Accepted Answer

Jim Hokanson
Jim Hokanson on 27 May 2012
I ended up entering the url being requested in Chrome. On the left side of the address there is a lock indicating the presence of a secure site. I clicked on it and chose to view certificate information. Under the details tab I was able to copy the certificate to a file. I chose the bottom (most specific certificate) to export and chose the default export options.
Next I found a lot of online discussion about a keystore. Disliking command line options, especially when it comes to long paths and debugging I found an application that seems to work well:
Of note, I also tried the Java window in the control panel (Windows 7) and this didn't work for me. I am guessing this is because it is tied to the main JRE on my computer, not the Mathworks JRE.
Apparently, for maximum awesomeness, Matlab ships with its own JRE, except for Macs where it uses the system's JRE. This seems like a bad design decision to me ... See:
Specifically, I think you need to update the cacerts file of the jre, which for me was located at: $Matlab/sys/java/jre/win64/jre/lib/security/cacerts
Using Portecle I opened this file and added the exported certificate. After importing I believe it also gave me a chain error (presumably since I hadn't exported the other certificates), but Portecle asked me if I wanted to trust it anyway, to which I replied yes.
Anyway, I really dislike any solution that requires me to do anything with the installation and operating system instead of from a function directly in Matlab. Any better solution?

  1 Comment

Chris Clarke
Chris Clarke on 27 Jan 2020 at 16:59
Im trying to install the compiler MinGW-w64 C/C++ (mingw.mlpkginstall)
I've got to the point where you open the file using Portecle but I'm getting "Enter Password"
Can anyone help with this?

Sign in to comment.

More Answers (0)

Sign in to answer this question.