module Ssl:sig
..end
type
ssl_error =
| |
Error_none |
(* |
No error happened. This is never raised and should disappear in future
versions.
| *) |
| |
Error_ssl |
|||
| |
Error_want_read |
(* |
The operation did not complete; the same TLS/SSL I/O function should be
called again later.
| *) |
| |
Error_want_write |
(* |
The operation did not complete; the same TLS/SSL I/O function should be
called again later.
| *) |
| |
Error_want_x509_lookup |
(* |
The 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_syscall |
(* |
Some I/O error occurred. The OpenSSL error queue may contain more
information on the error.
| *) |
| |
Error_zero_return |
(* |
The 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_connect |
(* |
The operation did not complete; the same TLS/SSL I/O function should be
called again later.
| *) |
| |
Error_want_accept |
(* |
The operation did not complete; the same TLS/SSL I/O function should be
called again later.
| *) |
typebigarray =
(char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t
exception Method_error
exception Context_error
exception Cipher_error
exception Diffie_hellman_error
exception Ec_curve_error
exception Certificate_error
exception Private_key_error
exception Unmatching_keys
exception Invalid_socket
exception Handler_error
exception Connection_error of ssl_error
exception Accept_error of ssl_error
exception Read_error of ssl_error
exception Write_error of ssl_error
type
verify_error =
| |
Error_v_unable_to_get_issuer_cert |
(* |
The issuer certificate could not be found: this occurs if the issuer
certificate of an untrusted certificate cannot be found.
| *) |
| |
Error_v_unable_to_get_ctl |
(* |
The CRL of a certificate could not be found.
| *) |
| |
Error_v_unable_to_decrypt_cert_signature |
(* |
The 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_signature |
(* |
The 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_key |
(* |
The public key in the certificate SubjectPublicKeyInfo could not be
read.
| *) |
| |
Error_v_cert_signature_failure |
(* |
The signature of the certificate is invalid.
| *) |
| |
Error_v_CRL_signature_failure |
(* |
The signature of the certificate is invalid.
| *) |
| |
Error_v_cert_not_yet_valid |
(* |
The certificate is not yet valid: the notBefore date is after the current
time.
| *) |
| |
Error_v_cert_has_expired |
(* |
The certificate has expired: that is the notAfter date is before the
current time.
| *) |
| |
Error_v_CRL_not_yet_valid |
(* |
The CRL is not yet valid.
| *) |
| |
Error_v_CRL_has_expired |
(* |
The CRL has expired.
| *) |
| |
Error_v_error_in_cert_not_before_field |
(* |
The certificate notBefore field contains an invalid time.
| *) |
| |
Error_v_error_in_cert_not_after_field |
(* |
The certificate notAfter field contains an invalid time.
| *) |
| |
Error_v_error_in_CRL_last_update_field |
(* |
The CRL lastUpdate field contains an invalid time.
| *) |
| |
Error_v_error_in_CRL_next_update_field |
(* |
The CRL nextUpdate field contains an invalid time.
| *) |
| |
Error_v_out_of_mem |
(* |
An error occurred trying to allocate memory. This should never happen.
| *) |
| |
Error_v_depth_zero_self_signed_cert |
(* |
The passed certificate is self signed and the same certificate cannot be
found in the list of trusted certificates.
| *) |
| |
Error_v_self_signed_cert_in_chain |
(* |
The 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_locally |
(* |
The 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_signature |
(* |
No signatures could be verified because the chain contains only one
certificate and it is not self signed.
| *) |
| |
Error_v_cert_chain_too_long |
(* |
The certificate chain length is greater than the supplied maximum
depth. Unused.
| *) |
| |
Error_v_cert_revoked |
(* |
The certificate has been revoked.
| *) |
| |
Error_v_invalid_CA |
(* |
A CA certificate is invalid. Either it is not a CA or its extensions are
not consistent with the supplied purpose.
| *) |
| |
Error_v_path_length_exceeded |
(* |
The basicConstraints pathlength parameter has been exceeded.
| *) |
| |
Error_v_invalid_purpose |
(* |
The supplied certificate cannot be used for the specified purpose.
| *) |
| |
Error_v_cert_untrusted |
(* |
The root CA is not marked as trusted for the specified purpose.
| *) |
| |
Error_v_cert_rejected |
(* |
The root CA is marked to reject the specified purpose.
| *) |
| |
Error_v_subject_issuer_mismatch |
(* |
The current candidate issuer certificate was rejected because its subject
name did not match the issuer name of the current certificate.
| *) |
| |
Error_v_akid_skid_mismatch |
(* |
The 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_mismatch |
(* |
The 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_certsign |
(* |
The current candidate issuer certificate was rejected because its keyUsage
extension does not permit certificate signing.
| *) |
| |
Error_v_application_verification |
(* |
An application specific error. Unused.
| *) |
exception Verify_error of verify_error
val init : ?thread_safe:bool -> unit -> unit
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.val get_error_string : unit -> string
type
protocol =
| |
SSLv23 |
(* |
accept all possible protocols (SSLv2 if supported by openssl,
SSLv3, TLSv1, TLSv1.1 and TLSv1.2)
| *) |
| |
SSLv3 |
(* |
only SSL v3 protocol
| *) |
| |
TLSv1 |
(* |
only TLS v1 protocol
| *) |
| |
TLSv1_1 |
(* |
only TLS v1.1 protocol
| *) |
| |
TLSv1_2 |
(* |
only TLS v1.2 protocol
| *) |
type
socket
Ssl_threads
module).val thread_safe : bool Pervasives.ref
type
context
type
context_type =
| |
Client_context |
(* |
Client connections.
| *) |
| |
Server_context |
(* |
Server connections.
| *) |
| |
Both_context |
(* |
Client and server connections.
| *) |
val create_context : protocol -> context_type -> context
val use_certificate : context -> string -> string -> unit
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.val set_password_callback : context -> (bool -> string) -> unit
false
) or writing/encryption (true
).val set_client_CA_list_from_file : context -> string -> unit
type
verify_mode =
| |
Verify_peer |
|||
| |
Verify_fail_if_no_peer_cert |
(* |
Implies
Verify_peer . | *) |
| |
Verify_client_once |
(* |
Implies
Verify_peer . | *) |
type
verify_callback
val client_verify_callback : verify_callback
val set_client_verify_callback_verbose : bool -> unit
Ssl.client_verify_callback
val set_verify : context -> verify_mode list -> verify_callback option -> unit
val set_verify_depth : context -> int -> unit
type
cipher
val disable_protocols : context -> protocol list -> unit
SSLv23
disables both SSLv2 and SSLv3 (as opposed to all the
protocols).
val set_cipher_list : context -> string -> unit
val honor_cipher_order : context -> unit
val init_dh_from_file : context -> string -> unit
val init_ec_from_named_curve : context -> string -> unit
val get_cipher : socket -> cipher
val get_cipher_description : cipher -> string
val get_cipher_name : cipher -> string
val get_cipher_version : cipher -> string
type
certificate
val read_certificate : string -> certificate
read_certificate fname
reads the certificate in the file fname
.val write_certificate : string -> certificate -> unit
val get_certificate : socket -> certificate
val get_issuer : certificate -> string
val get_subject : certificate -> string
val load_verify_locations : context -> string -> string -> unit
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).Invalid_argument
if both strings are empty or if one of the files
given in arguments could not be found.val get_verify_result : socket -> int
val embed_socket : Unix.file_descr -> context -> socket
val open_connection : protocol -> Unix.sockaddr -> socket
val open_connection_with_context : context -> Unix.sockaddr -> socket
val shutdown_connection : socket -> unit
open_connection
.val set_client_SNI_hostname : socket -> string -> unit
val connect : socket -> unit
val accept : socket -> unit
val flush : socket -> unit
val shutdown : socket -> unit
val verify : socket -> unit
verify_error
on failure.val file_descr_of_socket : socket -> Unix.file_descr
select
ing on it; you should not write or read on it.val read : socket -> Bytes.t -> int -> int -> int
read sock buf off len
receives data from a connected SSL socket.val write : socket -> string -> int -> int -> int
write sock buf off len
sends data over a connected SSL socket.val read_into_bigarray : socket -> bigarray -> int -> int -> int
read_into_bigarray sock ba off len
receives data from a connected SSL socket.
This function releases the runtime while the read takes place.val read_into_bigarray_blocking : socket -> bigarray -> int -> int -> int
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.val write : socket -> string -> int -> int -> int
write sock buf off len
sends data over a connected SSL socket.val write_bigarray : socket -> bigarray -> int -> int -> int
write_bigarray sock ba off len
sends data over a connected SSL socket.
This function releases the runtime while the read takes place.val write_bigarray_blocking : socket -> bigarray -> int -> int -> int
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.val input_string : socket -> string
val output_string : socket -> string -> unit
val input_char : socket -> char
val output_char : socket -> char -> unit
val input_int : socket -> int
val output_int : socket -> int -> unit