-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I get a SSL error swSSL_connection_error (ERRNO 1014) #2717
Comments
It's just a guess: If you use IP directly instead of hostname, try |
Thanks for your replying 🙏 No, I'm not connected with IP address directly.
Okay, What like you need information? In server-side
stream_context_set_option(
$context,
'ssl',
'local_cert',
'/path/to/file'
);
stream_context_set_option(
$context,
'ssl',
'local_pk',
'/path/to/file'
);
stream_context_set_option(
$context,
'ssl',
'allow_self_signed',
true
);
stream_context_set_option(
$context,
'ssl',
'verify_peer',
false
);
stream_context_set_option(
$context,
'ssl',
'verify_peer_name',
false
); Full code is here: https://github.com/memory-agape/magnolia-server/blob/master/src/magnolia/Traits/SecureConnectionManageable.php#L13
Server $server = stream_socket_server(
sprintf(
($this->isEnabledTLS() ? 'tls' : 'tcp') . '://%s:%d',
$this->getListenHost(),
$this->getListenPort(),
),
$errno,
$errstr,
STREAM_SERVER_BIND | STREAM_SERVER_LISTEN,
$context
);
stream_socket_enable_crypto($server, false); Connect accepting: while ($client = @stream_socket_accept($server, 0)) {
if ($this->isEnabledTLS()) {
stream_socket_enable_crypto(
$client,
true,
STREAM_CRYPTO_METHOD_TLSv1_2_SERVER
);
}
...
Detail code is here: https://github.com/memory-agape/magnolia-server/blob/master/src/magnolia/Server/GenericServer.php
In client-side
A packet data is: bytes(os.environ.get("AUTH_KEY", "").encode('utf-8')) + pack("L", len(frame)) + frame |
I got it. |
I will add some patches for SSL gradually |
Okay, Thanks twose! |
I just read the ssl options of context directly, then passed it to SW_API
stream_context_set_option(
$context,
'swoole',
'swoole_option_name',
$value
); |
OK, I'll try it. |
I removed the swoole context support after team discussion, and I rewrote the php ssl options to swoole: SSL_OPTION_ALIAS("peer_name", "ssl_hostname");
SSL_OPTION_ALIAS("verify_peer", "ssl_verify_peer");
SSL_OPTION_ALIAS("allow_self_signed", "ssl_allow_self_signed");
SSL_OPTION_ALIAS("cafile", "ssl_cafile");
SSL_OPTION_ALIAS("capath", "ssl_capath");
SSL_OPTION_ALIAS("local_cert", "ssl_cert_file");
SSL_OPTION_ALIAS("local_pk", "ssl_key_file");
SSL_OPTION_ALIAS("passphrase", "ssl_passphrase");
SSL_OPTION_ALIAS("verify_depth", "ssl_verify_depth");
SSL_OPTION_ALIAS("disable_compression", "ssl_disable_compression"); The above options are supported now You can close the issue if your application can work well, or continue to post questions |
Thanks! Twose. Hmm... but, I'm still getting the error... I changed Dockerfile: RUN git clone https://github.com/swoole/swoole-src.git
RUN cd swoole-src && \
git checkout master && \
phpize && \
./configure --enable-openssl && \
make && \
make install On the one hand, I'm replacing PHP native stream to |
|
Swoole does not support disable SSL dynamically |
In those days, I read this example for implementing my application. (but I knew that is unnecessary when using it is removed in my environment, but it is still getting the error. |
I built a docker-image with latest master. The error show when $wroteLength = fwrite($this->stream, $this->buffers);
if ($wroteLength < strlen($this->buffers)) {
echo 'Try to send: ' . implode(' ', str_split(bin2hex($this->buffers), 2)) . "\n";
}
echo 'Sent buffers: ' . ($wroteLength . '/' . strlen($this->buffers)) . "\n"; Output is shown below when the error has been shown.
|
You can use |
I tried to support the SSL dynamic switching, can you have a try |
All SSL proto errors are due to the underlying SSL handshake |
Thanks, I'll try it. |
I tried it. Unfortunately, I'm still getting the error.... 😭
|
@memory-agape |
If my understanding is mistaken, please tell me. I just changed code here: // $context = stream_context_create();
//
// if ($this->isEnabledTLS()) {
// // Write SSL Context
// $this->writeTLSContext($context);
// }
$server = stream_socket_server(
sprintf(
'tcp://%s:%d',
$this->getListenHost(),
$this->getListenPort(),
),
$errno,
$errstr,
STREAM_SERVER_BIND | STREAM_SERVER_LISTEN
);
// ...
while (true) {
try {
while ($client = @stream_socket_accept($server, 0)) {
if ($this->isEnabledTLS()) {
// Write SSL Context
$this->writeTLSContext($client);
stream_context_set_option(
$client,
'ssl',
'peer_name',
'magnolia-client.test'
);
stream_socket_enable_crypto(
$client,
true,
STREAM_CRYPTO_METHOD_TLSv1_2_SERVER
);
} It output is shown below:
And I changed By the way, I got SEGV with below code. if ($this->isEnabledTLS()) {
// Write SSL Context
$this->writeTLSContext($context);
}
$server = stream_socket_server(
sprintf(
'tls://%s:%d',
$this->getListenHost(),
$this->getListenPort(),
),
$errno,
$errstr,
STREAM_SERVER_BIND | STREAM_SERVER_LISTEN,
$context
);
// ...
while (true) {
try {
while ($client = @stream_socket_accept($server, 0)) {
if ($this->isEnabledTLS()) {
// Write SSL Context
$this->writeTLSContext($client);
stream_context_set_option(
$client,
'ssl',
'peer_name',
'magnolia-client.test'
);
stream_socket_enable_crypto(
$client,
true,
STREAM_CRYPTO_METHOD_TLSv1_2_SERVER
);
} It seems that duplicate enabling SSL. (this is a guess.) |
can you run |
I don't see the problem with your example, you can refer to the example above, try to reproduce this problem with the simplest code |
The first problem memory dump is here: The SEGV problem did not show when using
OK, It may take time 🙏 |
The log shows that the memory error originated from PHP's memory manager... It's rare, and I generally think that this is caused by something else... |
Are you talking about SEGV? And, I'm trying to reproduce the problem with simplest code. |
Please answer these questions before submitting your issue. Thanks!
Short Script.
$packet is an image data.
It is encoding text with WebSocket RFC.
Full code is here: https://github.com/memory-agape/magnolia-server/blob/master/src/magnolia/Client/Camera.php#L103
What did you expect to see?
Don't show errors.
What did you see instead?
What version of Swoole are you using (show your
php --ri swoole
)?OS: CentOS 7 on Docker
Details is here: https://github.com/memory-agape/magnolia-server/blob/master/infra/php/Dockerfile
The text was updated successfully, but these errors were encountered: