Matlab websave SSL certificates

Matlab websave uses weboptions to control HTTP behavior, including Timeout and SSL Certificate. SSL certificate checking can add security to web operations. Some systems may need environment variable SSL_CERT_FILE for Matlab’s vendored cURL.

As a last resort, certificate checking can be turned off, but this opens up code / file integrity and concomitant security issues. Instead of disabling certificate checking set environment variable SSL_CERT_FILE to the actual certificate location. This example sets reply timeout to 15 seconds and specifies custom SSL certificate location when environment variable SSL_CERT_FILE is set.

if isfile(getenv("SSL_CERT_FILE"))
  web_opts = weboptions(CertificateFilename=getenv("SSL_CERT_FILE"), Timeout=15);
  web_opts = weboptions(Timeout=15);

websave(saved_file, url, opts);

Alternative: cURL with Matlab