ObjectSslServer
sslServer object that facilitates the creation of a standard multi-fibersslserver
The SslServer object is theTcpServerandSslHandlerCombining encapsulated objects makes it easy to quickly build a server, which is logically equivalent to:
1
2
3var svr = new net.SslServer(addr, port, new ssl.Handler(crt, key, function(req) {
...
}));
Creation method:
1
2
3
4var ssl = require("ssl");
var svr = new http.Server(crt, key, function(req) {
...
});
inheritance relationship
Constructor
SslServer
SslServer constructor, listen on all local addresses
1
2
3new SslServer(Array certs,
Integer port,
Handler listener);
Call parameters:
- certs: Array, list of server certificates
- port: Integer, specifiedsslServer listening port
- listener:Handler, specifysslReceived built-in message processor, processing function, chain processing array, routing object, see detailsmq.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
4new SslServer(Array certs,
String addr,
Integer port,
Handler listener);
Call parameters:
- certs: Array, list of server certificates
- addr: String, specifysslServer listening address, if it is "", it will listen on all addresses of the local machine.
- port: Integer, specifiedsslServer listening port
- listener:Handler, specifysslThe built-in message processor, processing function, chain processing array, and routing object of the received connection. For details, seemq.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, listen on all local addresses
1
2
3
4new SslServer(X509Cert crt,
PKey key,
Integer port,
Handler listener);
Call parameters:
- crt:X509Cert,X509CertCertificate, used by clients to authenticate servers
- key:PKey,PKeyPrivate key, used to talk to the client
- port: Integer, specifiedsslServer listening port
- listener:Handler, specifysslReceived built-in message processor, processing function, chain processing array, routing object, see detailsmq.Handler
SslServer constructor
1
2
3
4
5new SslServer(X509Cert crt,
PKey key,
String addr,
Integer port,
Handler listener);
Call parameters:
- crt:X509Cert,X509CertCertificate, used by clients to authenticate servers
- key:PKey,PKeyPrivate key, used to talk to the client
- addr: String, specifysslServer listening address, if it is "", it will listen on all addresses of the local machine.
- port: Integer, specifiedsslServer listening port
- listener:Handler, specifysslThe built-in message processor, processing function, chain processing array, and routing object of the received connection. For details, seemq.Handler
member properties
verification
Integer, set the certificate verification mode, the default is VERIFY_NONE
1Integer SslServer.verification;
ca
X509Cert, client certificate verification certificate chain
1readonly X509Cert SslServer.ca;
socket
Socket, the server is currently listening toSocketobject
1readonly Socket SslServer.socket;
handler
Handler, the current event processing interface object of the server
1Handler SslServer.handler;
member function
start
Start current server
1SslServer.start();
stop
Close the socket to abort the running server
1SslServer.stop() async;
toString
Returns the string representation of the object. Generally, "[Native Object]" is returned. The object can be re-implemented according to its own characteristics.
1String SslServer.toString();
Return results:
- String, returns the string representation of the object
toJSON
Returns a JSON format representation of the object, generally returning a collection of readable properties defined by the object.
1Value SslServer.toJSON(String key = "");
Call parameters:
- key: String, not used
Return results:
- Value, returns a value containing JSON serializable