Page
Library
Module
Module type
Parameter
Class
Class type
Source
SslSourceFunctions for making encrypted communications using the Secure Socket Layer (SSL). These are mostly bindings to the openssl library.
type ssl_error = | Error_noneNo error happened. This is never raised and should disappear in future versions.
*)| Error_ssl| Error_want_readThe operation did not complete; the same TLS/SSL I/O function should be called again later.
*)| Error_want_writeThe operation did not complete; the same TLS/SSL I/O function should be called again later.
*)| Error_want_x509_lookupThe operation did not complete because an application callback set by set_client_cert_cb has asked to be called again. The TLS/SSL I/O function should be called again later. Details depend on the application.
| Error_syscallSome I/O error occurred. The OpenSSL error queue may contain more information on the error.
*)| Error_zero_returnThe TLS/SSL connection has been closed. If the protocol version is SSL 3.0 or TLS 1.0, this result code is returned only if a closure alert has occurred in the protocol, i.e. if the connection has been closed cleanly. Note that in this case Error_zero_return does not necessarily indicate that the underlying transport has been closed.
| Error_want_connectThe operation did not complete; the same TLS/SSL I/O function should be called again later.
*)| Error_want_acceptThe operation did not complete; the same TLS/SSL I/O function should be called again later.
*)An ssl error has occured (see SSL_get_error(3ssl) for details).
The SSL method could not be initalized.
The SSL server certificate could not be initialized.
The SSL server private key could not be intialized.
The SSL private key does not match the certificate public key.
The given socket is invalid.
The SSL handler could not be initialized.
type verify_error = | Error_v_unable_to_get_issuer_certThe issuer certificate could not be found: this occurs if the issuer certificate of an untrusted certificate cannot be found.
*)| Error_v_unable_to_get_ctlThe CRL of a certificate could not be found.
*)| Error_v_unable_to_decrypt_cert_signatureThe certificate signature could not be decrypted. This means that the actual signature value could not be determined rather than it not matching the expected value, this is only meaningful for RSA keys.
*)| Error_v_unable_to_decrypt_CRL_signatureThe CRL signature could not be decrypted: this means that the actual signature value could not be determined rather than it not matching the expected value. Unused.
*)| Error_v_unable_to_decode_issuer_public_keyThe public key in the certificate SubjectPublicKeyInfo could not be read.
*)| Error_v_cert_signature_failureThe signature of the certificate is invalid.
*)| Error_v_CRL_signature_failureThe signature of the certificate is invalid.
*)| Error_v_cert_not_yet_validThe certificate is not yet valid: the notBefore date is after the current time.
*)| Error_v_cert_has_expiredThe certificate has expired: that is the notAfter date is before the current time.
*)| Error_v_CRL_not_yet_validThe CRL is not yet valid.
*)| Error_v_CRL_has_expiredThe CRL has expired.
*)| Error_v_error_in_cert_not_before_fieldThe certificate notBefore field contains an invalid time.
*)| Error_v_error_in_cert_not_after_fieldThe certificate notAfter field contains an invalid time.
*)| Error_v_error_in_CRL_last_update_fieldThe CRL lastUpdate field contains an invalid time.
*)| Error_v_error_in_CRL_next_update_fieldThe CRL nextUpdate field contains an invalid time.
*)| Error_v_out_of_memAn error occurred trying to allocate memory. This should never happen.
*)| Error_v_depth_zero_self_signed_certThe passed certificate is self signed and the same certificate cannot be found in the list of trusted certificates.
*)| Error_v_self_signed_cert_in_chainThe certificate chain could be built up using the untrusted certificates but the root could not be found locally.
*)| Error_v_unable_to_get_issuer_cert_locallyThe issuer certificate of a locally looked up certificate could not be found. This normally means the list of trusted certificates is not complete.
*)| Error_v_unable_to_verify_leaf_signatureNo signatures could be verified because the chain contains only one certificate and it is not self signed.
*)| Error_v_cert_chain_too_longThe certificate chain length is greater than the supplied maximum depth. Unused.
*)| Error_v_cert_revokedThe certificate has been revoked.
*)| Error_v_invalid_CAA CA certificate is invalid. Either it is not a CA or its extensions are not consistent with the supplied purpose.
*)| Error_v_path_length_exceededThe basicConstraints pathlength parameter has been exceeded.
*)| Error_v_invalid_purposeThe supplied certificate cannot be used for the specified purpose.
*)| Error_v_cert_untrustedThe root CA is not marked as trusted for the specified purpose.
*)| Error_v_cert_rejectedThe root CA is marked to reject the specified purpose.
*)| Error_v_subject_issuer_mismatchThe current candidate issuer certificate was rejected because its subject name did not match the issuer name of the current certificate.
*)| Error_v_akid_skid_mismatchThe current candidate issuer certificate was rejected because its subject key identifier was present and did not match the authority key identifier current certificate.
*)| Error_v_akid_issuer_serial_mismatchThe current candidate issuer certificate was rejected because its issuer name and serial number was present and did not match the authority key identifier of the current certificate.
*)| Error_v_keyusage_no_certsignThe current candidate issuer certificate was rejected because its keyUsage extension does not permit certificate signing.
*)| Error_v_application_verificationAn application specific error. Unused.
*)Why did the certificate verification fail?
An error occured while verifying the certificate.
Initialize SSL functions. Should be called before calling any other function. The parameter thread_safe should be set to true if you use threads in you application (the same effect can achived by calling Ssl_threads.init first.
Retrieve a human-readable message that corresponds to the last error that occurred.
Protocol used by SSL.
An SSL abstract socket.
You should not have to use those functions. They are only here for internal use (they are needed to make the openssl library thread-safe, see the Ssl_threads module).
A context. A context should be created by a server or client once per program life-time and holds mainly default values for the SSL structures which are later created for the connections.
Type of the context to create.
Create a context.
Add an additional certificate to the extra chain certificates associated with the ctx. Extra chain certificates will be sent to the peer for verification and are sent in order following the end entity certificate. The value should be contents of the certificate as string in PEM format.
Add a certificate to the ctx trust storage. The value should be contents of the certificate as string in PEM format.
use_certificate ctx cert privkey makes the context ctx use cert as * certificate's file name (in PEM format) and privkey as private key file * name.
Use a certificate whose contents is given as argument (you should use instead use_certificate if you want to read the certificate from a file).
Set the callback function called to get passwords for encrypted PEM files. * The callback function takes a boolean argument which indicates if it's used * for reading/decryption (false) or writing/encryption (true).
Set the list of CAs sent to the client when requesting a client certificate.
Verification modes (see SSL_CTX_set_verify(3)).
A callback function for verification. Warning: this might change in the future.
Client's verification callback. Warning: this might change in the future.
Set verbosity of client_verify_callback
Set the verify mode and callback, see SSL_CTX_set_verify(3). * Warning: this might change in the future.
Set the maximum depth for the certificate chain verification that shall be allowed.
Set the list of supported ALPN protocols for negotiation to the context.
Set the callback to allow server to select the preferred protocol from client's available protocols.
A cipher. It holds the algorithm information for a particular cipher which * are a core part of the SSL/TLS protocol.
Disable all protocols from the list. * Note that SSLv23 disables both SSLv2 and SSLv3 (as opposed to all the * protocols). *
Set the list of available ciphers for a context. See man ciphers(1) for the format of the string.
When choosing a cipher, use the server's preferences instead of the client * preferences. When not set, the SSL server will always follow the clients * preferences. When set, the SSLv3/TLSv1 server will choose following its * own preferences. Because of the different protocol, for SSLv2 the server * will send its list of preferences to the client and the client chooses.
Get the version used for the connection. As per the OpenSSL documentation, should only be called after the initial handshake has been completed. Prior to that the results returned from these functions may be unreliable.
A certificate.
read_certificate fname reads the certificate in the file fname.
Get the certificate used by a socket.
Get the issuer of a certificate.
Get the subject of a certificate.
Get the start date of a certificate.
Get the expiration date of a certificate.
load_verify_locations ctxt cafile capath specifies the locations for the context ctx, at which CA certificates for verification purposes are located. cafile should be the name of a CA certificates file in PEM format and capath should be the name of a directory which contains CA certificates in PEM format. Empty strings can be used in order not to specify on of the parameters (but not both).
Specifies that the default locations from which CA certificates are loaded should be used. Returns true on success.
Get a human readable verification error message for the verification error Its input should be the result of calling get_verify_result.
Get the digest of the certificate as a binary string, using the SHA1, SHA256 or SHA384 hashing algorithm.
Embed a Unix socket into an SSL socket.
Open an SSL connection.
Open an SSL connection with the specified context.
Set the hostname the client is attempting to connect to using the Server * Name Indication (SNI) TLS extension.
Set the list of supported ALPN protocols for negotiation to the connection.
Get the negotiated protocol from the connection.
Send close notify to the peer. This is SSL_shutdown(3). * returns true if shutdown is finished, false in case close_notify * needs to be called a second time.
Close a SSL connection. * Send close notify to the peer and wait for close notify from peer.
Check the result of the verification of the X509 certificate presented by the peer, if any. Raises a verify_error on failure.
Flags to specify how a certificate is matched against a given host name
Set the expected ip address to be verified. Ip address is dotted decimal quad for IPv4 and colon-separated hexadecimal for IPv6. The condensed "::" notation is supported for IPv6 addresses.
Get the file descriptor associated with a socket. It is primarly useful for selecting on it; you should not write or read on it.
read sock buf off len receives data from a connected SSL socket.
read_into_bigarray sock ba off len receives data from a connected SSL socket. This function releases the runtime while the read takes place.
read_into_bigarray_blocking sock ba off len receives data from a connected SSL socket. This function DOES NOT release the runtime while the read takes place: it must be used with nonblocking sockets.
write sock buf off len sends data over a connected SSL socket.
write_substring sock str off len sends data over a connected SSL socket.
write_bigarray sock ba off len sends data over a connected SSL socket. This function releases the runtime while the read takes place.
write_bigarray sock ba off len sends data over a connected SSL socket. This function DOES NOT release the runtime while the read takes place: it must be used with nonblocking sockets.