66 * @version 1.0
77 * @author Serghey Rodin <skid@vestacp.com>
88 */
9-
10- function password_save ($ curpass , $ passwd )
9+ class rcube_vesta_password {
10+ function save ($ curpass , $ passwd )
1111 {
1212 $ rcmail = rcmail::get_instance ();
1313 $ vesta_host = $ rcmail ->config ->get ('password_vesta_host ' );
@@ -40,7 +40,16 @@ function password_save($curpass, $passwd)
4040 $ send .= PHP_EOL ;
4141 $ send .= $ postdata . PHP_EOL . PHP_EOL ;
4242
43- $ fp = fsockopen ('ssl:// ' . $ vesta_host , $ vesta_port );
43+ //$fp = fsockopen('ssl://' . $vesta_host, $vesta_port);
44+ $ errno = "" ;
45+ $ errstr = "" ;
46+ $ context = stream_context_create ();
47+
48+ $ result = stream_context_set_option ($ context , 'ssl ' , 'verify_peer ' , false );
49+ $ result = stream_context_set_option ($ context , 'ssl ' , 'verify_host ' , false );
50+ $ result = stream_context_set_option ($ context , 'ssl ' , 'allow_self_signed ' , true );
51+
52+ $ fp = stream_socket_client ('ssl:// ' . $ vesta_host . ': ' .$ vesta_port , $ errno , $ errstr , 60 , STREAM_CLIENT_CONNECT , $ context );
4453 fputs ($ fp , $ send );
4554 $ result = fread ($ fp , 2048 );
4655 fclose ($ fp );
@@ -60,3 +69,4 @@ function password_save($curpass, $passwd)
6069 }
6170
6271 }
72+ }
0 commit comments