Object built-in object

ObjectSslSocket

sslnetwork socket object

SslSocket belongs tosslmodule, creation method

1
var s = new ssl.Socket();

inheritance relationship

Constructor

SslSocket

SslSocket constructor, creates a new SslSocket object

1
new 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 2
new 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

1
Integer 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.

1
readonly X509Cert SslSocket.ca;

peerCert

X509Cert, connect the other party’s certificate

1
readonly X509Cert SslSocket.peerCert;

hostname

String, the hostname of the connection

1
readonly String SslSocket.hostname;

stream

Stream, query messagesslThe underlying flow object at creation time

1
readonly Stream SslSocket.stream;

fd

Integer, queryStreamThe corresponding file descriptor value, implemented by subclasses

1
readonly Integer SslSocket.fd;

member function

connect

Connect on the given connectionsslconnection, client mode

1 2
Integer 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

1
SslSocket 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

1
Buffer 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

1
SslSocket.write(Buffer data) async;

Call parameters:

  • data:Buffer, given the data to be written

flush

Write file buffer contents to physical device

1
SslSocket.flush() async;

close

Close the current stream object

1
SslSocket.close() async;

copyTo

Copy stream data to target stream

1 2
Long 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.

1
String 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.

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

Call parameters:

  • key: String, not used

Return results:

  • Value, returns a value containing JSON serializable