Object built-in object

Object SslServer

ssl Server object, can easily create a standard multi-fiber ssl server

The SslServer object is TcpServer with SslHandler Combining encapsulated objects makes it convenient to quickly build a server, which is logically equivalent to:

1 2 3
var svr = new net.SslServer(addr, port, new ssl.Handler(crt, key, function(req) { ... }));

Creation method:

1 2 3 4
var ssl = require("ssl"); var svr = new http.Server(crt, key, function(req) { ... });

Inheritance

#lineWidth: 1.5 #font: Helvetica,sans-Serif #fontSize: 10 #leading: 1.6 #.this: fill=lightgray #.class: fill=white [<class>object|toString();toJSON()] [<class>TcpServer|new TcpServer()|socket;handler|start();stop()] [<this>SslServer|new SslServer()|verification;ca] [object] <:- [TcpServer] [TcpServer] <:- [SslServer] TcpServer new TcpServer() socket handler start() stop() SslServer new SslServer() verification ca object toString() toJSON()

Constructor

SslServer

SslServer constructor, listening on all local addresses

1 2 3
new SslServer(Array certs, Integer port, Handler listener);

Call parameters:

  • certs: Array, server certificate list
  • port: Integer, specify ssl Server listening port
  • listener: Handler, Specify ssl The received built-in message processor, processing function, chain processing array, routing object, see details mq.Handler

The format of certs is:

1 2 3 4 5 6 7 8 9 10 11
[{ name: "fibjs.org", crt: [X509Cert object], key: [PKey object] }, { name: "*.fibjs.org", crt: [X509Cert object], key: [PKey object] } ]

SslServer constructor

1 2 3 4
new SslServer(Array certs, String addr, Integer port, Handler listener);

Call parameters:

  • certs: Array, server certificate list
  • addr: String, specify ssl Server listening address, "" means listening on all addresses of this machine
  • port: Integer, specify ssl Server listening port
  • listener: Handler, Specify ssl The built-in message handler, processing function, chain processing array, routing object of the received connection, see for details mq.Handler

The format of certs is:

1 2 3 4 5 6 7 8 9 10 11
[{ name: "fibjs.org", crt: [X509Cert object], key: [PKey object] }, { name: "*.fibjs.org", crt: [X509Cert object], key: [PKey object] } ]

SslServer constructor, listening on all local addresses

1 2 3 4
new SslServer(X509Cert crt, PKey key, Integer port, Handler listener);

Call parameters:

  • crt: X509Cert, X509Cert Certificate for client authentication server
  • key: PKey, PKey Private key, used to talk to the client
  • port: Integer, specify ssl Server listening port
  • listener: Handler, Specify ssl The received built-in message processor, processing function, chain processing array, routing object, see details mq.Handler

SslServer constructor

1 2 3 4 5
new SslServer(X509Cert crt, PKey key, String addr, Integer port, Handler listener);

Call parameters:

  • crt: X509Cert, X509Cert Certificate for client authentication server
  • key: PKey, PKey Private key, used to talk to the client
  • addr: String, specify ssl Server listening address, "" means listening on all addresses of this machine
  • port: Integer, specify ssl Server listening port
  • listener: Handler, Specify ssl The built-in message handler, processing function, chain processing array, routing object of the received connection, see for details mq.Handler

Member attributes

verification

Integer, set the certificate verification mode, the default is VERIFY_NONE

1
Integer SslServer.verification;

ca

X509Cert, Client certificate verification certificate chain

1
readonly X509Cert SslServer.ca;

socket

Socket, The server is currently listening Socket Object

1
readonly Socket SslServer.socket;

handler

Handler, Server current event processing interface object

1
Handler SslServer.handler;

Member function

start

Start the current server

1
SslServer.start();

stop

Close the socket to terminate the running server

1
SslServer.stop() async;

toString

Returns the string representation of the object, generally returns "[Native Object]", the object can be re-implemented according to its own characteristics

1
String SslServer.toString();

Return result:

  • String, Returns the string representation of the object

toJSON

Returns the JSON format representation of the object, generally returns a collection of readable attributes defined by the object

1
Value SslServer.toJSON(String key = "");

Call parameters:

  • key: String, unused

Return result:

  • Value, Returns a value containing JSON serializable