Skip to content

Commit 7743f3b

Browse files
authored
Allow Vesta Roundcube driver to comunicate with server even there is self signed SSL cert.
Previously fsockopen failed to connect on self-signed SSL cert. Code ported from Debian Vesta Roundcube driver.
1 parent 6a955cd commit 7743f3b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

install/rhel/6/roundcube/vesta.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,17 @@ function save($curpass, $passwd)
4242
$send .= PHP_EOL;
4343
$send .= $postdata . PHP_EOL . PHP_EOL;
4444

45-
$fp = fsockopen('ssl://' . $vesta_host, $vesta_port);
45+
//$fp = fsockopen('ssl://' . $vesta_host, $vesta_port);
46+
$errno = "";
47+
$errstr = "";
48+
$context = stream_context_create();
49+
50+
$result = stream_context_set_option($context, 'ssl', 'verify_peer', false);
51+
$result = stream_context_set_option($context, 'ssl', 'verify_host', false);
52+
$result = stream_context_set_option($context, 'ssl', 'allow_self_signed', true);
53+
54+
$fp = stream_socket_client('ssl://' . $vesta_host . ':'.$vesta_port, $errno, $errstr, 60, STREAM_CLIENT_CONNECT, $context);
55+
4656
fputs($fp, $send);
4757
$result = fread($fp, 2048);
4858
fclose($fp);

0 commit comments

Comments
 (0)