PHPoC activates an SSL function using the following two commands:
command | available F/W version |
---|---|
"set api ssl" | all |
"set api tls" | 1.5.0 or later |
The result of the two commands are identical.
The following example shows how to use it as an SSL server.
<?php
$port = 1470; // port number
$pid = pid_open("/mmap/tcp0"); // open TCP 0
pid_ioctl($pid, "set api ssl"); // set api to SSL
pid_ioctl($pid, "set ssl method server"); // set SSL server mode
pid_bind($pid, "", $port); // binding
pid_listen($pid); // listen TCP connection
do
$state = pid_ioctl($pid, "get state");
while(($state != SSL_CLOSED) && ($state != SSL_CONNECTED));
if($state == SSL_CONNECTED)
{
echo "Connection has been established!\r\n";
pid_close($pid); // close TCP connection
}
?>
※ It is necessary to store a certification into PHPoC before you use it as a SSL server. Create or save a certificate to your product by PHPoC Debugger.
The following example shows how to use PHPoC as an SSL client.
<?php
$addr = "10.1.0.2"; // server's IP address
$port = 1470; // server's port number
$pid = pid_open("/mmap/tcp0"); // open TCP 0
pid_ioctl($pid, "set api ssl"); // set api to SSL
pid_ioctl($pid, "set ssl method client"); // set SSL client mode
pid_bind($pid, "", 0); // binding
pid_connect($pid, $addr, $port); // connect to TCP server
do
$state = pid_ioctl($pid, "get state");
while(($state != SSL_CLOSED) && ($state != SSL_CONNECTED));
if($state == SSL_CONNECTED)
{
echo "Connection has been established!\r\n";
pid_close($pid); // close TCP connection
}
?>
※ SSL communication may not be performed in case of lack of memory caused by increased memory usage of PHPoC.