Comments (5)
https://github.com/sskaje/mqtt/blob/master/test/tls1.2/connect.php
is this what you want?
from mqtt.
yes。thank you。
from mqtt.
请问ssl的证书要在哪里设置?看test上好像没有配置证书的路径。
from mqtt.
http://php.net/stream_context_create
http://php.net/manual/en/context.ssl.php
from mqtt.
Hi
A small contribution to this issue.
Here is how I use TLS with this library, and it works. The code below is reactored to drop specificies of my project and make it more understandable.
/**
* Builds a MQTT
* @param string $socketAddress
* @param integer $port
* @param boolean $isTls
* @return sskaje\mqtt\MQTT an instance of a MQTT client
*/
protected function buildMqtt($socketAddress, $port, $isTls) {
$protocol = $isTls ? "ssl://" : "tcp://";
$mqtt = new sskaje\mqtt\MQTT("$protocol$socketAddress:$port");
if ($isTls) {
$mqtt->setSocketContext(stream_context_create([
'ssl' => [
'cafile' => '/path/to/CACert-mqtt.crt',
'verify_peer' => false,
'verify_peer_name' => false,
'disable_compression' => true,
'ciphers' => 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-ECDSA-RC4-SHA:AES128:AES256:RC4-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK',
'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT | STREAM_CRYPTO_METHOD_SSLv23_CLIENT,
'SNI_enabled' => true,
'allow_self_signed' => true
]
]
));
}
$mqtt->setKeepalive(50);
return $mqtt;
}
from mqtt.
Related Issues (20)
- 参数暗示 参数类型好像有问题 HOT 5
- Enforce TLS v1.2 documentation HOT 2
- Unknown error if the client is not authorized to connect HOT 2
- Exception thrown when a PUBLISH message has an particular length HOT 2
- the new v2.0 can not use in product env HOT 8
- message content trunkated on publish, missing part sent on next publish and so on..
- WTFFF! (Exception PHP Notice: fwrite(): send of x bytes failed with errno=11 Resource temporarily unavailable in ..ocketClient.php on line 166) [FIX] HOT 2
- A typo in the source code
- Header Timestamp always 1970-01-01T01:00:00+01:00 HOT 2
- Release 2.0?
- message_read throw Exception
- MQTT 5.0 HOT 2
- last update on packagist.org is 2018-03-16 HOT 2
- How I can get client id in subscribe.php? HOT 1
- How to use puback()?
- Bad check for multiple topic subscribe/unsubscribe.
- Unable to Subscribe when Published HOT 6
- do_publish is public : is it wanted ? HOT 2
- endless ping sent if pipe breaks HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mqtt.