From e20fb92789b0f156691f9624e549fc58c71d34c4 Mon Sep 17 00:00:00 2001 From: flightonary Date: Sun, 11 Jan 2015 15:37:49 +0900 Subject: [PATCH] Update README.md --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index f4d76b6..fbf8377 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ $ git submodule update Usage ----- +Here is a basic sample. ```swift import Moscapsule @@ -46,6 +47,25 @@ mqttClient.subscribe("subscribe/topic", qos: 2) mqttClient.disconnect() ``` +The framework supports TLS_PSK, Server and/or Client certification. +Here is a server certificate sample. +```swift +import Moscapsule + +// Note that you must initialize framework only once after launch application +// in case that it uses SSL/TLS functions. +moscapsule_init() + +let mqttConfig = MQTTConfig(clientId: "server_cert_test", host: "test.mosquitto.org", port: 8883, keepAlive: 60) + +let bundlePath = NSBundle(forClass: self.dynamicType).bundlePath.stringByAppendingPathComponent("cert.bundle") +let certFile = bundlePath.stringByAppendingPathComponent("mosquitto.org.crt") + +mqttConfig.mqttServerCert = MQTTServerCert(cafile: certFile, capath: nil) + +let mqttClient = MQTT.newConnection(mqttConfig) +``` + License ------- The MIT License (MIT)