SSL context options
SSL context option listing
Description
Context options for ssl:// and tls:// transports.
Options
peer_namestringPeer name to be used. If this value is not set, then the name is guessed based on the hostname used when opening the stream.
verify_peerboolRequire verification of SSL certificate used.
Defaults to true.
verify_peer_nameboolRequire verification of peer name.
Defaults to true.
allow_self_signedboolAllow self-signed certificates. Requires
verify_peer.Defaults to false
cafilestringLocation of Certificate Authority file on local filesystem which should be used with the
verify_peercontext option to authenticate the identity of the remote peer.capathstringIf
cafileis not specified or if the certificate is not found there, the directory pointed to bycapathis searched for a suitable certificate.capathmust be a correctly hashed certificate directory.local_certstringPath to local certificate file on filesystem. It must be a PEM encoded file which contains your certificate and private key. It can optionally contain the certificate chain of issuers. The private key also may be contained in a separate file specified by
local_pk.local_pkstringPath to local private key file on filesystem in case of separate files for certificate (
local_cert) and private key.passphrasestringPassphrase with which your
local_certfile was encoded.verify_depthintAbort if the certificate chain is too deep.
Defaults to no verification.
ciphersstringSets the list of available ciphers. The format of the string is described in ciphers(1).
Defaults to
DEFAULT.capture_peer_certboolIf set to true a
peer_certificatecontext option will be created containing the peer certificate.capture_peer_cert_chainboolIf set to true a
peer_certificate_chaincontext option will be created containing the certificate chain.SNI_enabledboolIf set to true server name indication will be enabled. Enabling SNI allows multiple certificates on the same IP address.
SNI_server_certsarrayAn array of server names and their corresponding certificates to be used for SNI. The keys are the server names and the values are the paths to the certificate files on the local filesystem. The certificate files must be PEM encoded and contain both the certificate and private key.
Available as of PHP 5.6.0.
alpn_protocolsarrayAn array of application layer protocol names to be used for ALPN (Application-Layer Protocol Negotiation). The values are the protocol names as strings (e.g. "http/1.1", "h2").
Available as of PHP 7.0.0 and OpenSSL 1.0.2.
no_ticketboolIf set, disable TLS session tickets. This can help to enhance security by providing Perfect Forward Secrecy (PFS).
Available as of PHP 5.3.6.
disable_compressionboolIf set, disable TLS compression. This can help mitigate the CRIME attack vector.
peer_fingerprintstring|arrayAborts when the remote certificate digest doesn't match the specified hash.
When a
stringis used, the length will determine which hashing algorithm is applied, either "md5" (32) or "sha1" (40).When an
arrayis used, the keys indicate the hashing algorithm name and each corresponding value is the expected digest.security_levelintSets the security level. If not specified the library default security level is used. The security levels are described in SSL_CTX_get_security_level(3).
Available as of PHP 7.2.0 and OpenSSL 1.1.0.
min_proto_versionintSets the minimum protocol version allowed. If not specified the library default minimum protocol version is used. The protocol versions are described in SSL_CTX_set_min_proto_version(3).
Available as of PHP 7.3.0 and OpenSSL 1.1.0.
max_proto_versionintSets the maximum protocol version allowed. If not specified the library default maximum protocol version is used. The protocol versions are described in SSL_CTX_set_max_proto_version(3).
Available as of PHP 7.3.0 and OpenSSL 1.1.0.
Changelog
| Version | Description |
|---|---|
| 7.3.0 | Added min_proto_version and max_proto_version. Requires OpenSSL >= 1.1.0. |
| 7.2.0 | Added security_level. Requires OpenSSL >= 1.1.0. |
| 7.0.0 | Added alpn_protocols. Requires OpenSSL >= 1.0.2. |
| 5.6.0 | Added SNI_server_certs. |
| 5.3.6 | Added no_ticket. |
Notes
Because ssl:// is the underlying transport for the https:// and ftps:// wrappers, any context options which apply to ssl:// also apply to https:// and ftps://.
For SNI (Server Name Indication) to be available, then PHP must be compiled with OpenSSL 0.9.8j or greater. Use the OPENSSL_TLSEXT_SERVER_NAME to determine whether SNI is supported.