Skip to content

Commit

Permalink
Fix swoole_runtime/ssl tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Nov 5, 2024
1 parent 6d35c00 commit 2dd90db
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
12 changes: 4 additions & 8 deletions ext-src/swoole_runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -781,19 +781,15 @@ static int socket_enable_crypto(php_stream *stream, Socket *sock, php_stream_xpo
if (!sock->ssl_handshake()) {
return -1;
}
zval *val = php_stream_context_get_option(context, "ssl", "capture_peer_cert");
if (val && zend_is_true(val) && !php_openssl_capture_peer_certs(stream, sock)) {
return -1;
}
/**
* returns 1: The TLS/SSL handshake was successfully completed, a TLS/SSL connection has been established.
*/
return 1;
} else if (!cparam->inputs.activate && sock->ssl_is_available()) {
sock->ssl_shutdown();
return -1;
}

zval *val = php_stream_context_get_option(context, "ssl", "capture_peer_cert");
if (val && zend_is_true(val) && !php_openssl_capture_peer_certs(stream, sock)) {
return -1;
}
return 1;
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/swoole_coroutine_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ class Socket {
return ssl_context.get();
}

bool ssl_listen();
bool ssl_handshake();
bool ssl_verify(bool allow_self_signed);
std::string ssl_get_peer_cert();
Expand Down Expand Up @@ -443,6 +442,7 @@ class Socket {
std::string ssl_host_name;
bool ssl_context_create();
bool ssl_create(SSLContext *ssl_context);
bool ssl_listen();
#endif

bool connected = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
--TEST--
swoole_runtime: ssl capture_peer_cert
swoole_runtime/ssl: capture_peer_cert
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
require __DIR__ . '/../../include/skipif.inc';
skip_if_no_ssl();
skip_if_offline();
?>
--FILE--
<?php
require __DIR__ . '/../include/bootstrap.php';
require __DIR__ . '/../../include/bootstrap.php';

function capture_peer_cert($domain)
{
Expand All @@ -32,7 +32,7 @@ function capture_peer_cert($domain)

Swoole\Runtime::setHookFlags(SWOOLE_HOOK_ALL);

Co\run(function () {
Co\run(function () {
$result = capture_peer_cert('www.baidu.com');
$info1 = openssl_x509_parse($result["options"]["ssl"]["peer_certificate"]);
Assert::isArray($info1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
swoole_runtime: ssl client
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
require __DIR__ . '/../../include/skipif.inc';
skip_if_no_ssl();
skip_if_offline();
?>
--FILE--
<?php
require __DIR__ . '/../include/bootstrap.php';
require __DIR__ . '/../../include/bootstrap.php';

Swoole\Runtime::enableCoroutine();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
swoole_runtime: ssl server
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
require __DIR__ . '/../../include/skipif.inc';
skip_if_no_ssl();
?>
--FILE--
<?php
require __DIR__ . '/../include/bootstrap.php';
require __DIR__ . '/../../include/bootstrap.php';

Swoole\Runtime::enableCoroutine();

Expand Down

0 comments on commit 2dd90db

Please sign in to comment.