Object built-in object

Object SslSocket

ssl network socket object

SslSocket belongs to the ssl module, creation method

1
var s = new ssl.Socket();

Inheritance

Constructor

SslSocket

SslSocket constructor to create a new SslSocket object

1
new SslSocket(Array certs = []);

Call parameters:

  • certs : Array, server certificate list

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 to create a new SslSocket object

1 2
new SslSocket(X509Cert crt, PKey key);

Call parameters:

  • crt : X509Cert , X509Cert certificate, used for client authentication server
  • key : PKey , PKey private key, used to talk to the client

Member attributes

verification

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

1
Integer SslSocket.verification;

ca

X509Cert , certificate chain, automatically refer to ssl.ca when connect in client mode, and generate SslSocket in server mode accept automatically refer to the ca of current SslSocket

1
readonly X509Cert SslSocket.ca;

peerCert

X509Cert , connect the other party's certificate

1
readonly X509Cert SslSocket.peerCert;

hostname

String, the host name of the connection

1
readonly String SslSocket.hostname;

stream

Stream , query the lower stream object when the message ssl established

1
readonly Stream SslSocket.stream;

Member function

connect

Connect ssl connection on the given connection, client mode

1 2
Integer SslSocket.connect(Stream s, String server_name = "") async;

Call parameters:

  • s : Stream , the given underlying connection
  • server_name : String, specify the server name, default

Return result:

  • Integer , return 0 if the connection is successful, non-zero if the certificate is optional verification, if the verification is unsuccessful, see the ssl module for detailed errors

accept

Receive an ssl connection on a given connection and generate a new SslSocket

1
SslSocket SslSocket.accept(Stream s) async;

Call parameters:

  • s : Stream , the given underlying connection

Return result:

  • SslSocket , returns the newly created SslSocket object

read

Read data of the specified size from the stream

1
Buffer SslSocket.read(Integer bytes = -1) async;

Call parameters:

  • bytes : Integer, specify 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 result:

  • Buffer , returns the data read from the stream, if there is no data to read, or the connection is interrupted, it returns null

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 the contents of the file buffer to the physical device

1
SslSocket.flush() async;

close

Close the current stream object

1
SslSocket.close() async;

copyTo

Copy stream data to the target stream

1 2
Long SslSocket.copyTo(Stream stm, Long bytes = -1) async;

Call parameters:

  • stm : Stream , target stream object
  • bytes : Long, the number of bytes copied

Return result:

  • Long , returns the number of bytes copied

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 SslSocket.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 SslSocket.toJSON(String key = "");

Call parameters:

  • key : String, unused

Return result:

  • Value , returns a value containing JSON serializable