lmssl reference
Complete command-line flag reference, host schema contexts and methods, X.509 and TLS types, standard lmcode_std_v3 REST and CLI interfaces, and exit codes for lmssl v0.2.1 (bundling OpenSSL 4.0.3).
Host and CLI flags
| Flag or command | Arguments | Description |
|---|---|---|
| --version | none | Print the lmssl and embedded OpenSSL version string (lmssl 0.2.1 (OpenSSL 4.0.3 29 Sep 2026)) and exit 0. |
| --lmcode | <file.dslb> [args...] | Validate and execute a compiled LMScript bytecode part; repeatable for multi-part runs with per-part ssl.args(). |
| --dry-run | --lmcode <file.dslb> | Validate bytecode loading and run in dry mode without key generation, file writes, or socket operations. |
| --json | --lmcode <file.dslb> | Compatibility flag accepted for _lmcode_ invocations (all _lmcode_ runs emit a terminal JSON SDK frame on stdout). |
| --lmcode-schema | [--json] | Print a human-readable schema summary, or exact embedded schema JSON bytes when --json is passed. |
| --lmcode-signatures | none | Print all 360 canonical context, function, and method signatures (134 host + 226 standard library). |
| <openssl-cmd> | [openssl-args...] | Any other command (version, req, x509, ca, s_client, enc, dgst, pkcs12, cms, ocsp, ...) runs OpenSSL 4.0.3 directly. |
Ssl, Key, Csr, and Cert methods
| Type / context | Method signature | Description |
|---|---|---|
| context ssl: Ssl | ssl.version() -> string | ssl.args() -> StrList | ssl.now() -> string | ssl.monotonic_us() -> int | Return the OpenSSL version string, per-part CLI arguments, current UTC timestamp string, or monotonic microseconds. |
| Ssl (encoding / random) | ssl.hex(string) | ssl.unhex(string) | ssl.b64(string) | ssl.unb64(string) -> string | ssl.rand_bytes(int) | ssl.rand_hex(int) -> string | Convert between raw byte strings and lowercase hex or Base64, or generate cryptographically secure random bytes/hex. |
| Ssl (crypto) | ssl.digest(string, string) -> string | ssl.hmac(string, string, string) -> string | ssl.pbkdf2(string, string, int, string, int) -> string | Compute lowercase hex message digest (alg, data), HMAC (alg, key, data), or PBKDF2 key (alg, pass, iter, salt_hex, len). |
| Ssl (AEAD) | ssl.seal(string, string, string, string, string) -> string | ssl.open(string, string, string, string, string) -> string | Encrypt or decrypt with AES-128-GCM, AES-256-GCM, or ChaCha20-Poly1305 (cipher, key_hex, iv_hex, aad, plain_or_ct_hex). |
| Ssl (keys) | ssl.gen_rsa(int) | ssl.gen_ec(string) | ssl.gen_ed25519() -> Key | ssl.load_key(string[, string]) | ssl.parse_key(string) -> Key | Generate RSA (bits), EC (P-256, P-384, P-521), or Ed25519 keys, or load/parse a PEM private key (with optional passphrase). |
| Ssl (certs / CSRs) | ssl.new_cert(Key, string) | ssl.cert_from_csr(Csr) | ssl.load_cert(string) | ssl.parse_cert(string) -> Cert | Create an X.509 certificate template from a key and subject DN or CSR, or load/parse an existing PEM certificate. |
| Ssl (CSR / TLS ctx) | ssl.new_csr(Key, string) | ssl.load_csr(string) -> Csr | ssl.client_ctx() -> TlsCtx | ssl.server_ctx(Cert, Key) -> TlsCtx | Create or load a PKCS#10 CSR, or create a client or server TLS context. |
| Key | k.type() | k.curve() | k.pem() | k.public_pem() | k.text() | k.fingerprint() -> string | k.bits() -> int | Inspect key algorithm, curve name, private/public PEM, human-readable OpenSSL dump, SHA-256 public key fingerprint, or bit size. |
| Key | k.save(string) | k.save_encrypted(string, string) -> void | k.sign(string, string) -> string | k.verify(string, string, string) -> bool | Save private key PEM with 0600 permissions (plain or passphrase-encrypted), or sign/verify data with digest and hex signature. |
| Csr | csr.san(string) | csr.sign(Key, string) -> Csr | csr.verify() -> bool | csr.subject() | csr.pem() | csr.text() -> string | csr.save(string) -> void | Add Subject Alternative Names, sign or verify the CSR, inspect subject/PEM/text, or save to disk. |
| Cert (builders) | c.serial(int) | c.valid_days(int) | c.valid_between(string, string) | c.san(string) | c.ca(bool) | c.ext(string, string) -> Cert | Configure serial number, validity window, comma-separated SANs (DNS:...,IP:...), CA basicConstraint, or arbitrary X.509v3 extensions. |
| Cert (signing) | c.sign_self(Key, string) -> Cert | c.sign_with(Cert, Key, string) -> Cert | Finalize standard extensions (SKI, AKI, basicConstraints) and self-sign or sign with an issuer Cert and Key. |
| Cert (inspectors) | c.subject() | c.issuer() | c.serial_hex() | c.not_before() | c.not_after() | c.san_text() | c.sig_alg() | c.key_type() | c.fingerprint(string) | c.pem() | c.text() -> string | Inspect certificate DNs, serial, validity timestamps, SANs, signature/key algorithms, digest fingerprint, PEM, or full text dump. |
| Cert (predicates) | c.is_ca() | c.self_signed() | c.expired() | c.matches_host(string) | c.verify_with(Cert) -> bool | c.save(string) -> void | Check CA flag, self-signed status, expiration, hostname/SAN match, cryptographic signature by an issuer Cert, or write PEM to disk. |
Net, Conn, Listener, TlsCtx, Tls, Fs, and Out methods
| Type / context | Method signature | Description |
|---|---|---|
| context net: Net | net.resolve(string) -> StrList | net.connect(string, int) -> Conn | net.listen(int) -> Listener | net.timeout(int) -> void | Resolve a hostname to IP strings, open a TCP connection, bind a local TCP listener (port 0 chooses an ephemeral port), or set socket timeout seconds. |
| Conn | conn.peer() | conn.local() -> string | conn.write(string) -> int | conn.read(int) | conn.read_until(string, int) -> string | conn.close() -> void | Inspect remote/local address:port, read or write plain TCP bytes, read until delimiter up to max bytes, or close the connection. |
| Listener | l.port() -> int | l.accept() -> Conn | l.close() -> void | Return the bound TCP port, accept an incoming TCP connection, or close the listener. |
| TlsCtx | ctx.min_version(string) | ctx.max_version(string) | ctx.alpn(string) | ctx.ciphers(string) | ctx.suites(string) | ctx.groups(string) -> TlsCtx | Configure TLS protocol bounds (TLS1.2, TLS1.3), comma-separated ALPN protocols, TLS 1.2 ciphers, TLS 1.3 cipher suites, or key-share groups. |
| TlsCtx | ctx.verify(bool) | ctx.ca_file(string) | ctx.add_ca(Cert) | ctx.system_roots() | ctx.chain(Cert) | ctx.client_cert(Cert, Key) | ctx.require_client(bool) | ctx.trace(bool) -> TlsCtx | Configure peer verification, trust anchors, intermediate chain certs, client mTLS certificate, mandatory client auth, or handshake message tracing. |
| TlsCtx | ctx.connect(Conn, string) -> Tls | ctx.accept(Conn) -> Tls | Perform a client TLS handshake (with SNI and hostname verification) or server TLS handshake over an open Conn. |
| Tls | tls.version() | tls.cipher() | tls.group() | tls.peer_sigalg() | tls.alpn() | tls.server_name() | tls.verify_result() | tls.trace() -> string | tls.verified() -> bool | Inspect negotiated TLS version, cipher, key-exchange group, signature scheme, ALPN, SNI, X.509 verification status, or recorded handshake trace. |
| Tls | tls.peer() -> Cert | tls.chain_len() -> int | tls.chain_at(int) -> Cert | Retrieve the peer's leaf certificate or inspect certificates in the presented peer chain. |
| Tls | tls.write(string) -> int | tls.read(int) | tls.read_until(string, int) | tls.read_all(int) -> string | tls.shutdown() -> void | Write or read application data over the encrypted TLS stream or send a close_notify alert. |
| context fs: Fs | fs.read(string) -> string | fs.write(string, string) | fs.write_private(string, string) | fs.mkdir(string) | fs.remove(string) -> void | fs.exists(string) -> bool | Read and write files (write_private enforces mode 0600), check path existence, create directories, or remove paths. |
| context out: Out / functions | out.line(string) | out.text(string) | out.warn(string) | out.fail(string) | print(string) | assert_close(float, float, float) -> void | Write diagnostic output to stderr, abort execution with APP_FAIL (exit code 4), print to stdout, or assert floating-point tolerance. |
Standard lmcode_std_v3 REST and CLI interfaces
| Interface or function | Signature / annotation | Description |
|---|---|---|
| RestGet .. RestOptions | @"/path/:param" fn h(x: RestExchange) -> void implements RestGet | Bind an HTTP GET, POST, PUT, DELETE, PATCH, HEAD, or OPTIONS route handler. |
| RestHandler | @"/path" fn h(x: RestExchange) -> void implements RestHandler | Bind a method-agnostic HTTP route handler. |
| CliCommand | @"cmd" fn h(x: RestExchange) -> void implements CliCommand | Bind a named CLI subcommand dispatched by rest_cli. |
| CliOption | @"--flag" fn h(x: RestExchange) -> void implements CliOption | Bind a CLI option flag (--flag=val or --flag val) evaluated before the command handler. |
| rest_config | rest_config(key: string, value: string) -> void | Configure server or CLI settings such as host, port, and session (ephemeral or global). |
| rest_route | rest_route(method: string, path: string, handler: string) -> void | Dynamically register an HTTP method and route pattern to a handler function name. |
| rest_serve / rest_stop | rest_serve() -> void | rest_stop() -> void | Start or stop the embedded standard HTTP server loop. |
| rest_cli | rest_cli(args: StrList) -> string | Dispatch CLI options, commands, or path requests in-process without opening a socket. |
| RestExchange | x.method() | x.path() | x.body() | x.param(string) | x.query(string) | x.header(string) -> string | Read request method, path, body, :param segment, query parameter, or header. |
| RestExchange | x.has_query(string) | x.has_header(string) -> bool | Check whether a query parameter or request header is present. |
| RestExchange | x.status(int) | x.set_header(string, string) | x.send(string) | x.json(string) -> void | Set response status code and headers, and emit plain text or application/json bodies. |
| RestExchange | x.get(string) -> string | x.set(string, string) -> void | x.increment(string) -> int | Read, write, or atomically increment session state keys across global or ephemeral exchanges. |
Exit codes
| Exit code | Category | Meaning |
|---|---|---|
| 0 | Success | All _lmcode_ bytecode parts or introspection commands succeeded and all assertions passed. |
| 2 | CLI / metadata error | Malformed host command-line invocation or missing required --lmcode argument. |
| 3 | Load / host run error | Bytecode load failure, schema SHA-256 mismatch, or runtime host error (RUN_HOST, such as TLS handshake failure or invalid cipher input). |
| 4 | Application failure | Script called out.fail(msg) or failed an assertion contract (code APP_FAIL). |
| 0..255 | Native OpenSSL CLI mode | When invoked with an OpenSSL subcommand (req, x509, s_client, ...), returns OpenSSL 4.0.3's native exit code. |