@@ -8,8 +8,8 @@ var net = require('net')
8
8
, MqttSecureServer = require ( './server' ) . MqttSecureServer
9
9
, MqttClient = require ( './client' )
10
10
, MqttConnection = require ( './connection' )
11
- , tls = require ( " tls" )
12
- , fs = require ( "fs" ) ;
11
+ , tls = require ( ' tls' )
12
+ , fs = require ( 'fs' ) ;
13
13
14
14
var defaultPort = 1883
15
15
, defaultHost = 'localhost' ;
@@ -134,14 +134,26 @@ module.exports.createServer = function(listener) {
134
134
/**
135
135
* createSecureServer - create a tls secured MQTT server
136
136
*
137
+ * @param {Object } opts - server options
138
+ * - OR
137
139
* @param {String } keyPath - path to private key
138
140
* @param {String } certPath - path to public cert
139
- * @param {Function } listener - called on new client conns
141
+ * @param {Function } [ listener] - called on new client conns
140
142
*/
141
-
142
143
module . exports . createSecureServer =
143
- function ( keyPath , certPath , listener ) {
144
- return new MqttSecureServer ( keyPath , certPath , listener ) ;
144
+ function ( keyPath , certPath , listener ) {
145
+ var opts = { } ;
146
+
147
+ // Deprecated style
148
+ if ( 'string' === typeof keyPath && 'string' === typeof certPath ) {
149
+ // TODO: deprecation warning?
150
+ opts . key = fs . readFileSync ( keyPath ) ;
151
+ opts . cert = fs . readFileSync ( certPath ) ;
152
+ } else if ( 'object' === typeof keyPath ) {
153
+ opts = keyPath ;
154
+ }
155
+
156
+ return new MqttSecureServer ( opts , listener ) ;
145
157
} ;
146
158
147
159
/**
0 commit comments