======set_cert_key======
WMMEGA FW >= 2.1198
Set a custom certificate for TLS
====Description====
set_cert_key (
string
$key,
string
$cert
)
This function lets you use a custom certificate for HTTPS transactions.
====Parameter====
$key: The contents of the PEM key file
$cert: The contents of the CRT file
====Return Values====
int - 0 for success or else the failure code
====Example====
This example assumes you have two files obtained from your certificate provider and have uploaded them into a /cert/ subfolder on the SD card.
$cert_file=fopen("/cert/certificate.pem.crt","r");
$cert=fread($cert_file,filesize($cert_file));
fclose($cert_file);
$key_file=fopen("/cert/private.pem.key","r");
$key=fread($key_file,filesize($key_file));
fclose($key_file);
$res=set_cert_key($key,$cert);
$host='www.your_secure_host.com';
$sock=fsockopen($host,443,70);
if ($sock) {
print("Socket Opened!");
// do something
} else {
print("TLS certificate seems to not be working.");
}
?>