carbond.SslOptions¶
Instances of this class represent a set of ssl related options for an ObjectServer. Options mostly mirror those of the Node.js tls and https modules.
Configuration¶
{
_type: carbon.carbond.SslOptions,
serverCertPath: <string>,
serverKeyPath: <string>,
[serverKeyPassphrase: <string>],
[trustedCertsPaths = <string>],
[crl: <string>],
[ciphers: <string>],
[ecdhCurve (<string> | false)],
[dhparam: <string],
[handshakeTimeout: <number>],
[honorCipherOrder: <boolean>],
[requestCert: <boolean>],
[rejectUnauthorized: <boolean>],
[checkServerIdentity = <function>],
[NPNProtocols: (<Array> | <Buffer)],
[SNICallback: <function>],
[sessionTimeout: <number>],
[ticketKeys: <Buffer>],
[sessionIdContext: <string>],
[secureProtocol: <string>],
[secureOptions: <string>]
}
Properties¶
- ¶
checkServerIdentity(servername, cert) functionDefault nullDescription Provide an override for checking server’s hostname against the certificate. Should return an error if verification fails. Return undefined if passing.
- ¶
ciphers stringDefault nullDescription A string describing the ciphers to use or exclude. See note on the BEAST attack here.
- ¶
crl stringDefault nullDescription Either a string or list of strings of PEM encoded CRLs (Certificate Revocation List).
- ¶
dhparam stringDefault nullDescription DH parameter file to use for DHE key agreement. Use openssl dhparam command to create it. If the file is invalid to load, it is silently discarded.
- ¶
ecdhCurve string|booleanDefault nullDescription A string describing a named curve to use for ECDH key agreement or false to disable ECDH.
- ¶
handshakeTimeout stringDefault nullDescription Abort the connection if the SSL/TLS handshake does not finish in this many milliseconds. The default is 120 seconds.
- ¶
honorCipherOrder booleanDefault nullDescription When choosing a cipher, use the server’s preferences instead of the client preferences.
- ¶
NPNProtocols objectDefault nullDescription An array of possible NPN protocols. (Protocols should be ordered by their priority).
rejectUnauthorized booleanDefault falseDescription If true the server will reject any connection which is not authorized with the list of supplied CAs. This option only has an effect if requestCert is true. Default: false.
- ¶
requestCert booleanDefault falseDescription If true the server will request a certificate from clients that connect and attempt to verify that certificate. Default: false.
- ¶
SNICallback (servername, cb) functionDefault nullDescription A function that will be called if client supports SNI TLS extension. Two argument will be passed to it: servername, andcb.SNICallbackshould invokecb(null, ctx), where ctx is aSecureContextinstance. (You can usetls.createSecureContext(...)to get properSecureContext). IfSNICallbackwasn’t provided - default callback with high-level API will be used.
- ¶
secureOptions stringDefault nullDescription Set server options. For example, to disable the SSLv3 protocol set the SSL_OP_NO_SSLv3flag. See SSL_CTX_set_options for all available options.
- ¶
secureProtocol stringDefault TLSv1_methodDescription The SSL method to use, e.g. SSLv3_methodto force SSL version 3. The possible values depend on your installation of OpenSSL and are defined in the constantSSL_METHODS.
- ¶
serverCertPath stringDefault nullDescription The path to the server certificate.
- ¶
serverKeyPassPhrase stringDefault nullDescription A string of passphrase for the private key or pfx.
- ¶
serverKeyPath stringDefault nullDescription The path to the private key.
- ¶
sessionIdContext objectDefault nullDescription A string containing an opaque identifier for session resumption. If requestCertistrue, the default is MD5 hash value generated from command-line. Otherwise, the default is not provided.
- ¶
sessionTimeout numberDefault nullDescription An integer specifying the seconds after which TLS session identifiers and TLS session tickets created by the server are timed out. See SSL_CTX_set_timeout for more details.
- ¶
ticketKeys objectDefault nullDescription A 48-byte Bufferinstance consisting of 16-byte prefix, 16-byte hmac key, 16-byte AES key. You could use it to accept tls session tickets on multiple instances of tls server.
- ¶
trustedCertsPaths stringDefault nullDescription A path or array of paths to find trusted CA certificates.
Methods¶
- ¶
isEnabled () Arguments undefinedReturns undefinedDescriptions Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolo re magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Du is a ute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cu pidatat non proi dent, sunt in culpa qui officia deserunt mollit anim id est laborum.
- ¶
asHttpsOptions () Arguments undefinedReturns objectDescriptions Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolo re magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Du is a ute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cu pidatat non proi dent, sunt in culpa qui officia deserunt mollit anim id est laborum.
Examples¶
var carbon = require('carbon-io')
var o = carbon.atom.o(module)
var __ = carbon.fiber.__(module, true)
var path = require('path')
__(function() {
module.exports = o({
_type: carbon.carbond.ObjectServer,
port: 8888,
sslOptions: {
serverCertPath: path.join(__dirname, 'cert.pem'),
serverKeyPath: path.join(__dirname, 'key.pem')
},
endpoints : {
"hello": o({
_type: carbon.carbond.Endpoint,
get: function(req) {
return { "msg" : "Hello world!" }
}
})
}
})
})