EMILUA(3em)
π EMILUA π
ok so this is the EMILUA(3em) page from the Emilua reference β she's the Lua execution engine bestie, and today we're doing the TLS context glow-up. grab a strawberry drink π and let's go.
β¨ NAME β¨
Emilua β the Lua execution engine. that's the whole vibe. no cap. π
π₯ FUNCTIONS π₯
πΈ new(method: string) β tls.context
the constructor, the main character, the moment. π
method has got to be one of these or it's not happening:
"sslv2""sslv2_client""sslv2_server""sslv3""sslv3_client""sslv3_server""tlsv1""tlsv1_client""tlsv1_server""sslv23""sslv23_client""sslv23_server""tlsv11""tlsv11_client""tlsv11_server""tlsv12""tlsv12_client""tlsv12_server""tlsv13""tlsv13_client""tlsv13_server""tls""tls_client""tls_server"
like i said. all of them. we don't skip. π
π add_certificate_authority(self, data: byte_span)
drops in a certification authority so the verification can actually happen. it's giving trust issues but make it productive. π«Ά
π add_verify_path(self, path: filesystem.path)
points at a whole directory of certificate authority files to use when verifying. bulk energy.
π§Ή clear_options(self, flags: string[])
wipes options off the context. flags in, flags gone. iconic.
π load_verify_file(self, filename: filesystem.path)
loads a certification authority file for doing the verification. one file, one job. β
π£οΈ set_default_verify_paths(self)
sets the context up to use the default directories when hunting for certification authority certificates. set it and forget it, lowkey. β¨
βοΈ set_options(self, flags: string[])
the opposite of clear β puts options on the context. (there's a whole list of valid flags down in FUNCTION FLAGS, iykyk π)
π set_password_callback(self, callback: function)
sets the password callback. the signature has to be exactly this, no improvising:
function callback(max_length: integer, purpose: string) -> string
and purpose is gonna be either "for_reading" or "for_writing".
β οΈ Note: this callback gets called from an unspecified fiber where IO/blocking operations are disabled. so likeβ¦ don't go blocking in there, bestie, fr fr. π
β
set_verify_callback(self, callback: string[, callback_options...])
sets the callback used to verify peer certificates. right now there is exactly one supported callback:
"host_name_verification"β and thencallback_optionsis a single string holding the host name.
that's it. that's the list. π
π set_verify_depth(self, depth: integer)
sets the peer verification depth. a number. a limit. boundaries are healthy. π¦
π‘οΈ set_verify_mode(self, mode: string)
sets the peer verification mode. mode might be one of:
"none"."peer"."fail_if_no_peer_cert"."client_once".
π use_certificate(self, data: byte_span, fmt: string)
uses a certificate straight out of a memory buffer. fmt might be one of:
"asn1"β ASN.1 file."pem"β PEM file.
π use_certificate_chain(self, data: byte_span)
uses a certificate chain from a memory buffer. it's a chain. it's a vibe. βοΈ
π use_certificate_chain_file(self, filename: filesystem.path)
same chain energy, but from a file this time.
π use_certificate_file(self, filename: filesystem.path, fmt: string)
uses a certificate from a file. fmt might be one of:
"asn1"β ASN.1 file."pem"β PEM file.
ποΈ use_private_key(self, data: byte_span, fmt: string)
uses a private key from a memory buffer. (private!! π) fmt might be one of:
"asn1"β ASN.1 file."pem"β PEM file.
ποΈ use_private_key_file(self, filename: filesystem.path, fmt: string)
uses a private key from a file. fmt might be one of:
"asn1"β ASN.1 file."pem"β PEM file.
π use_rsa_private_key(self, data: byte_span, fmt: string)
uses an RSA private key from a memory buffer. fmt might be one of:
"asn1"β ASN.1 file."pem"β PEM file.
π use_rsa_private_key_file(self, filename: filesystem.path, fmt: string)
uses an RSA private key from a file. fmt might be one of:
"asn1"β ASN.1 file."pem"β PEM file.
π use_tmp_dh(self, data: byte_span)
uses the given memory buffer to get the temporary Diffie-Hellman parameters. iconic name, honestly.
π use_tmp_dh_file(self, filename: filesystem.path)
uses the given file to get the temporary Diffie-Hellman parameters. same thing, file edition. π
π© FUNCTION FLAGS π©
these are the flags you'd be passing to set_options / clear_options. every single one is the flag with the same name in Boost.Asio, and here's what each one has to say for itself:
π§Έ default_workarounds
the flag of the same name in Boost.Asio β https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/ssl__context_base/default_workarounds.html β and it says:
"Implement various bug workarounds."
we love a flag that just handles it for us. π
π€ no_compression
the flag of the same name in Boost.Asio β https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/ssl__context_base/no_compression.html β and it says:
"Disable compression. Compression is disabled by default."
so likeβ¦ it's already off, but now it's officially off. π
π« no_sslv2
the flag of the same name in Boost.Asio β https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/ssl__context_base/no_sslv2.html β and it says:
"Disable SSL v2."
π« no_sslv3
the flag of the same name in Boost.Asio β https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/ssl__context_base/no_sslv3.html β and it says:
"Disable SSL v3."
π« no_tlsv1
the flag of the same name in Boost.Asio β https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/ssl__context_base/no_tlsv1.html β and it says:
"Disable TLS v1."
π« no_tlsv1_1
the flag of the same name in Boost.Asio β https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/ssl__context_base/no_tlsv1_1.html β and it says:
"Disable TLS v1.1."
π« no_tlsv1_2
the flag of the same name in Boost.Asio β https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/ssl__context_base/no_tlsv1_2.html β and it says:
"Disable TLS v1.2."
π« no_tlsv1_3
the flag of the same name in Boost.Asio β https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/ssl__context_base/no_tlsv1_3.html β and it says:
"Disable TLS v1.3."
π single_dh_use
the flag of the same name in Boost.Asio β https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/ssl__context_base/single_dh_use.html β and it says:
"Always create a new key when using tmp_dh parameters."
fresh key every time. main character energy, no recycling. π
ok that's the whole page, we ate and left zero crumbs. πβ¨
signing off on behalf of Emilua 0.12.1-nixpkgs1, dated 1980-01-01 β the EMILUA(3em) girlies stay timeless. mwah ππ«Ά
π¦ where this page comes from
- nixos 26.05: emilua 0.12.1
- nixpkgs unstable: emilua 0.12.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms