ObjectSslSocket
sslnetwork socket object
SslSocket belongs tosslmodule, creation method
1var s = new ssl.Socket();
inheritance relationship
Constructor
SslSocket
SslSocket constructor, creates a new SslSocket object
1new SslSocket(Array certs = []);
Call parameters:
- certs: Array, list of server certificates
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]
}
]
SslSocket constructor, creates a new SslSocket object
1
2new SslSocket(X509Cert crt,
PKey key);
Call parameters:
- crt:X509Cert,X509CertCertificate, used by clients to authenticate servers
- key:PKey,PKeyPrivate key, used to talk to the client
member properties
verification
Integer, set the certificate verification mode, the default is VERIFY_REQUIRED
1Integer SslSocket.verification;
ca
X509Cert, certificate chain, automatically referenced when connecting in client modessl.ca, server mode accept generates SslSocket and automatically references the ca of the current SslSocket.
1readonly X509Cert SslSocket.ca;
peerCert
X509Cert, connect the other party’s certificate
1readonly X509Cert SslSocket.peerCert;
hostname
String, the hostname of the connection
1readonly String SslSocket.hostname;
stream
Stream, query messagesslThe underlying flow object at creation time
1readonly Stream SslSocket.stream;
fd
Integer, queryStreamThe corresponding file descriptor value, implemented by subclasses
1readonly Integer SslSocket.fd;
member function
connect
Connect on the given connectionsslconnection, client mode
1
2Integer SslSocket.connect(Stream s,
String server_name = "") async;
Call parameters:
- s:Stream, given the underlying connection
- server_name: String, specifies the server name, can be defaulted
Return results:
- Integer, returns 0 if the connection is successful. When the certificate verification is optional, non-0 will be returned if the verification is unsuccessful. For detailed errors, seesslmodule
accept
Receives asslConnect and generate a new SslSocket
1SslSocket SslSocket.accept(Stream s) async;
Call parameters:
- s:Stream, given the underlying connection
Return results:
- SslSocket, returns the newly created SslSocket object
read
Read data of specified size from the stream
1Buffer SslSocket.read(Integer bytes = -1) async;
Call parameters:
- bytes: Integer, specifies the amount of data to be read. The default is to read data blocks of random size. The size of the data read depends on the device.
Return results:
- Buffer, returns the data read from the stream. If there is no data to read or the connection is interrupted, null is returned.
write
Write the given data to the stream
1SslSocket.write(Buffer data) async;
Call parameters:
- data:Buffer, given the data to be written
flush
Write file buffer contents to physical device
1SslSocket.flush() async;
close
Close the current stream object
1SslSocket.close() async;
copyTo
Copy stream data to target stream
1
2Long SslSocket.copyTo(Stream stm,
Long bytes = -1) async;
Call parameters:
- stm:Stream, target stream object
- bytes: Long, number of bytes copied
Return results:
- Long, returns the number of bytes copied
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 SslSocket.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 SslSocket.toJSON(String key = "");
Call parameters:
- key: String, not used
Return results:
- Value, returns a value containing JSON serializable