mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-05 17:30:27 +00:00
Finish writing documentation, fix segfaults?
This commit is contained in:
parent
88d2662664
commit
81bc69fa43
2 changed files with 25 additions and 3 deletions
|
@ -7985,7 +7985,27 @@ function unix.Errno:__tostring() end
|
||||||
---@param hostname string for validating that the hostname on the certificate matches what is expected
|
---@param hostname string for validating that the hostname on the certificate matches what is expected
|
||||||
---@return crypto.tls.Connection
|
---@return crypto.tls.Connection
|
||||||
---@nodiscard
|
---@nodiscard
|
||||||
function crypto.tls.wrap(fd, hostname)
|
function crypto.tls.wrap(fd, hostname) end
|
||||||
|
|
||||||
|
--- Read data from the TLS connection.
|
||||||
|
---
|
||||||
|
--- This call is blocking.
|
||||||
|
---@param bufsize integer # the maximum amount of data to read from the connection.
|
||||||
|
---@return string # any data read from the connection.
|
||||||
|
function crypto.tls.Connection:read() end
|
||||||
|
|
||||||
|
--- Write data to the TLS connection.
|
||||||
|
---
|
||||||
|
--- This call is blocking.
|
||||||
|
---@param data string # the data to write to the connection.
|
||||||
|
---@return nil
|
||||||
|
function crypto.tls.Connectino:write() end
|
||||||
|
|
||||||
|
--- Close the connection.
|
||||||
|
---
|
||||||
|
--- Also closes the underlying socket.
|
||||||
|
---@return nil
|
||||||
|
function crypto.tls.Connection:close() end
|
||||||
-- CONSTANTS
|
-- CONSTANTS
|
||||||
|
|
||||||
---@type integer for debug logging level. See `Log`.
|
---@type integer for debug logging level. See `Log`.
|
||||||
|
|
|
@ -5159,13 +5159,15 @@ int LuaCryptoTlsConnectionRead(lua_State *L) {
|
||||||
lua_Integer bufsiz;
|
lua_Integer bufsiz;
|
||||||
bufsiz = luaL_optinteger(L, 2, BUFSIZ);
|
bufsiz = luaL_optinteger(L, 2, BUFSIZ);
|
||||||
bufsiz = MIN(bufsiz, 0x7ffff00);
|
bufsiz = MIN(bufsiz, 0x7ffff00);
|
||||||
buf = _gc(malloc(bufsiz));
|
buf = malloc(bufsiz);
|
||||||
rc = TlsConnectionRead(GetTlsConnection(L), buf, bufsiz);
|
rc = TlsConnectionRead(GetTlsConnection(L), buf, bufsiz);
|
||||||
if (rc != -1) {
|
if (rc != -1) {
|
||||||
got = rc;
|
got = rc;
|
||||||
lua_pushlstring(L, buf, got);
|
lua_pushlstring(L, buf, got);
|
||||||
|
free(buf);
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
|
free(buf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5229,7 +5231,7 @@ int LuaCryptoTlsWrap(lua_State *L) {
|
||||||
} else if (rc == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED) {
|
} else if (rc == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED) {
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
return LuaNilTlsError(
|
return LuaNilTlsError(
|
||||||
L, _gc(DescribeSslVerifyFailure(conn->ctx.session_negotiate->verify_result)), rc
|
L, DescribeSslVerifyFailure(conn->ctx.session_negotiate->verify_result), rc
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue