You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-2Lines changed: 23 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,6 +43,27 @@ let publish = MQTTPublishInfo(
43
43
)
44
44
try client.publish(info: publish).wait()
45
45
```
46
-
## WebSockets and SSL
46
+
## TLS
47
47
48
-
There is support for WebSockets and TLS connections. You can enable these through the `Configuration` provided at initialization. For TLS connections set`Configuration.useSSL` to `true` and provide your SSL certificates via the `Configuration.tlsConfiguration` struct. For WebSockets set `Configuration.useWebSockets` to `true` and set the URL path in `Configuration.webSocketsURLPath`.
48
+
MQTT NIO supports TLS connections. You can enable these through the `Configuration` provided at initialization. Set`Configuration.useSSL` to `true` and provide your SSL certificates via the `Configuration.tlsConfiguration` struct. For example to connect to the mosquitto test server `test.mosquitto.org` on port 8884 you need to provide their certificate and your own certificate. They provide details on the website [https://test.mosquitto.org/](https://test.mosquitto.org/) on how to generate your own certificates.
49
+
50
+
```swift
51
+
let rootCertificate =try NIOSSLCertificate.fromPEMBytes([UInt8](mosquittoCertificateText.utf8))
52
+
let myCertificate =try NIOSSLCertificate.fromPEMBytes([UInt8](myCertificateText.utf8))
53
+
let myPrivateKey =tryNIOSSLPrivateKey(bytes: [UInt8](myPrivateKeyText.utf8), format: .pem)
54
+
let tlsConfiguration: TLSConfiguration?= TLSConfiguration.forClient(
MQTT also supports Web Socket connections. Set `Configuration.useWebSockets` to `true` and set the URL path in `Configuration.webSocketsURLPath` to enable these.
0 commit comments