kafein
Types
Record to describe a certificate
pub type Certificate {
Certificate(
certfile: String,
keyfile: String,
password: option.Option(fn() -> String),
)
}
Constructors
-
Certificate( certfile: String, keyfile: String, password: option.Option(fn() -> String), )
Error that can occur on some operation.
For more details, check out the Erlang docs:
pub type Error {
Closed
Options(dynamic.Dynamic)
Other(dynamic.Dynamic)
TcpError(mug.Error)
CipherSuiteNotRecognized(name: String)
TlsAlert(kind: TlsAlertKind, description: String)
}
Constructors
-
ClosedConnection was closed
-
Options(dynamic.Dynamic)An opaque error meant for debugging
-
Other(dynamic.Dynamic)An opaque error meant for debugging
-
TcpError(mug.Error)Error that comes from the connection
-
CipherSuiteNotRecognized(name: String)A specified cipher suite was not recognized
-
TlsAlert(kind: TlsAlertKind, description: String)Error that comes from the TLS interaction
Enum of supported protocol version
pub type ProtocolVersion {
Tlsv1
Tlsv1m1
Tlsv1m2
Tlsv1m3
}
Constructors
-
Tlsv1 -
Tlsv1m1 -
Tlsv1m2 -
Tlsv1m3
An SSL Socket, upgraded form of TCP socket used for sending and receiving TCP messages.
pub type SslSocket
Error that might occur throughout the lifetime of the socket, see https://www.erlang.org/doc/apps/ssl/ssl.html#t:tls_alert/0.
pub type TlsAlertKind {
CloseNotify
UnexpectedMessage
BadRecordMac
RecordOverflow
HandshakeFailure
BadCertificate
UnsupportedCertificate
CertificateRevoked
CertificateExpired
CertificateUnknown
IllegalParameter
UnknownCa
AccessDenied
DecodeError
DecryptError
ExportRestriction
ProtocolVersion
InsufficientSecurity
InternalError
InappropriateFallback
UserCanceled
NoRenegotiation
UnsupportedExtension
CertificateUnobtainable
UnrecognizedName
BadCertificateStatusResponse
BadCertificateHashValue
UnknownPskIdentity
NoApplicationProtocol
}
Constructors
-
CloseNotify -
UnexpectedMessage -
BadRecordMac -
RecordOverflow -
HandshakeFailure -
BadCertificate -
UnsupportedCertificate -
CertificateRevoked -
CertificateExpired -
CertificateUnknown -
IllegalParameter -
UnknownCa -
AccessDenied -
DecodeError -
DecryptError -
ExportRestriction -
ProtocolVersion -
InsufficientSecurity -
InternalError -
InappropriateFallback -
UserCanceled -
NoRenegotiation -
UnsupportedExtension -
CertificateUnobtainable -
UnrecognizedName -
BadCertificateStatusResponse -
BadCertificateHashValue -
UnknownPskIdentity -
NoApplicationProtocol
Enum of verification type
pub type VerificationType {
VerifyNone
VerifyPeer
}
Constructors
-
VerifyNone -
VerifyPeer
Record to describe options when wrapping a TCP socket
pub type WrapOptions {
WrapOptions(
protocol_versions: List(ProtocolVersion),
alpn: List(String),
cacertfile: option.Option(String),
cipher_suites: List(String),
depth: Int,
verify: VerificationType,
certificates: List(Certificate),
)
}
Constructors
-
WrapOptions( protocol_versions: List(ProtocolVersion), alpn: List(String), cacertfile: option.Option(String), cipher_suites: List(String), depth: Int, verify: VerificationType, certificates: List(Certificate), )
Values
pub fn receive(
socket: SslSocket,
timeout_miliseconds timeout: Int,
) -> Result(BitArray, mug.Error)
pub fn receive_exact(
socket: SslSocket,
byte_size size: Int,
timeout_miliseconds timeout: Int,
) -> Result(BitArray, mug.Error)
pub fn receive_next_packet_as_message(socket: SslSocket) -> Nil
pub fn select_ssl_messages(
selector: process.Selector(t),
mapper: fn(SslMessage) -> t,
) -> process.Selector(t)
pub fn send_builder(
socket: SslSocket,
data: bytes_tree.BytesTree,
) -> Result(Nil, mug.Error)
pub fn unsafe_cast(value: a) -> b
pub fn wrap(
socket: mug.Socket,
options opts: WrapOptions,
) -> Result(SslSocket, Error)
Upgrades a TCP connection to SSL connection.
Returns an error if upgrading was failed.