W3cubDocs

/Dart 2

SecurityContext class

The object containing the certificates to trust when making a secure client connection, and the certificate chain and private key to serve from a secure server.

The SecureSocket and SecureServerSocket classes take a SecurityContext as an argument to their connect and bind methods.

Certificates and keys can be added to a SecurityContext from either PEM or PKCS12 containers.

iOS note: Some methods to add, remove, and inspect certificates are not yet implemented. However, the platform's built-in trusted certificates can be used, by way of SecurityContext.defaultContext.

Constructors

SecurityContext({bool withTrustedRoots: false })
factory
Creates a new SecurityContext. [...]

Properties

hashCodeint
read-only, inherited
The hash code for this object. [...]
runtimeTypeType
read-only, inherited
A representation of the runtime type of the object.

Methods

setAlpnProtocols(List<String> protocols, bool isServer) → void
Sets the list of application-level protocols supported by a client connection or server connection. The ALPN (application level protocol negotiation) extension to TLS allows a client to send a list of protocols in the TLS client hello message, and the server to pick one and send the selected one back in its server hello message. [...]
setClientAuthorities(String file, { String password }) → void
Sets the list of authority names that a SecureServerSocket will advertise as accepted when requesting a client certificate from a connecting client. [...]
setClientAuthoritiesBytes(List<int> authCertBytes, { String password }) → void
Sets the list of authority names that a SecureServerSocket will advertise as accepted, when requesting a client certificate from a connecting client. [...]
setTrustedCertificates(String file, { String password }) → void
Sets the set of trusted X509 certificates used by SecureSocket client connections, when connecting to a secure server. [...]
setTrustedCertificatesBytes(List<int> certBytes, { String password }) → void
Sets the set of trusted X509 certificates used by SecureSocket client connections, when connecting to a secure server. [...]
useCertificateChain(String file, { String password }) → void
Sets the chain of X509 certificates served by SecureServerSocket when making secure connections, including the server certificate. [...]
useCertificateChainBytes(List<int> chainBytes, { String password }) → void
Sets the chain of X509 certificates served by SecureServerSocket when making secure connections, including the server certificate. [...]
usePrivateKey(String file, { String password }) → void
Sets the private key for a server certificate or client certificate. [...]
usePrivateKeyBytes(List<int> keyBytes, { String password }) → void
Sets the private key for a server certificate or client certificate. [...]
noSuchMethod(Invocation invocation) → dynamic
inherited
Invoked when a non-existent method or property is accessed. [...]
toString() → String
inherited
Returns a string representation of this object.

Operators

operator ==(dynamic other) → bool
inherited
The equality operator. [...]

Static Properties

alpnSupportedbool
read-only
Whether the platform supports ALPN. This always returns true and will be removed in a future release.
defaultContextSecurityContext
read-only
Secure networking classes with an optional context parameter use the defaultContext object if the parameter is omitted. This object can also be accessed, and modified, directly. Each isolate has a different defaultContext object. The defaultContext object uses a list of well-known trusted certificate authorities as its trusted roots. On Linux and Windows, this list is taken from Mozilla, who maintains it as part of Firefox. On, MacOS, iOS, and Android, this list comes from the trusted certificates stores built in to the platforms.

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/2.0.0/dart-io/SecurityContext-class.html