Object built-in object

Object SslServer

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

The SslServer object is an object that combines TcpServer and SslHandler , which is convenient to quickly build a server. It 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

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 the listening port of the ssl server
  • listener : Handler , specify the built-in message handler, processing function, chain processing array, routing object received by ssl , see mq.Handler details

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 the listening address of the ssl server, if it is "", it will listen on all addresses of this machine
  • port : Integer, specify the listening port of the ssl server
  • listener : Handler , specify the built-in message handler, processing function, chain processing array, routing object of the connection received by ssl , see mq.Handler details

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, used for client authentication server
  • key : PKey , PKey private key, used to talk to the client
  • port : Integer, specify the listening port of the ssl server
  • listener : Handler , specify the built-in message handler, processing function, chain processing array, routing object received by ssl , see mq.Handler details

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, used for client authentication server
  • key : PKey , PKey private key, used to talk to the client
  • addr : String, specify the listening address of the ssl server, if it is "", it will listen on all addresses of this machine
  • port : Integer, specify the listening port of the ssl server
  • listener : Handler , specify the built-in message handler, processing function, chain processing array, routing object of the connection received by ssl , see mq.Handler details

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 Socket object currently listening by the server

1
readonly Socket SslServer.socket;

handler

Handler , the server's 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