Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump to Mojo 24.6 #3

Merged
merged 19 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,3 @@ jobs:
run: |
source $HOME/.bash_profile
magic run tests
magic run benchmarks
magic run examples
4,330 changes: 3,720 additions & 610 deletions magic.lock

Large diffs are not rendered by default.

152 changes: 152 additions & 0 deletions main.mojo
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
from src.rustls import *
from src.libc import *

fn main():
var cert_path = to_char_ptr("/etc/ssl/cert.pem")

var config = RustlsClientConfig()

var root_cert_store_builder = new_root_cert_store_builder()
var result = load_roots_from_file(root_cert_store_builder, cert_path, False)

print("Result: ", result)
# const char *hostname = argv[1];
# const char *port = argv[2];
# const char *path = argv[3];

# /* Set this global variable for logging purposes. */
# programname = "client";

# const struct rustls_crypto_provider *custom_provider = NULL;
# struct rustls_client_config_builder *config_builder = NULL;
# struct rustls_root_cert_store_builder *server_cert_root_store_builder = NULL;
# const struct rustls_root_cert_store *server_cert_root_store = NULL;
# const struct rustls_client_config *client_config = NULL;
# struct rustls_web_pki_server_cert_verifier_builder
# *server_cert_verifier_builder = NULL;
# struct rustls_server_cert_verifier *server_cert_verifier = NULL;
# struct rustls_slice_bytes alpn_http11;
# const struct rustls_certified_key *certified_key = NULL;

# alpn_http11.data = (unsigned char *)"http/1.1";
# alpn_http11.len = 8;

# #ifdef _WIN32
# WSADATA wsa;
# WSAStartup(MAKEWORD(1, 1), &wsa);
# setmode(STDOUT_FILENO, O_BINARY);
# #endif

# const char *custom_ciphersuite_name = getenv("RUSTLS_CIPHERSUITE");
# if(custom_ciphersuite_name != NULL) {
# custom_provider =
# default_provider_with_custom_ciphersuite(custom_ciphersuite_name);
# if(custom_provider == NULL) {
# goto cleanup;
# }
# printf("customized to use ciphersuite: %s\n", custom_ciphersuite_name);

# result = rustls_client_config_builder_new_custom(custom_provider,
# default_tls_versions,
# default_tls_versions_len,
# &config_builder);
# if(result != RUSTLS_RESULT_OK) {
# print_error("creating client config builder", result);
# goto cleanup;
# }
# }
# else {
# config_builder = rustls_client_config_builder_new();
# }

# if(getenv("RUSTLS_PLATFORM_VERIFIER")) {
# result = rustls_platform_server_cert_verifier(&server_cert_verifier);
# if(result != RUSTLS_RESULT_OK) {
# fprintf(stderr, "client: failed to construct platform verifier\n");
# goto cleanup;
# }
# rustls_client_config_builder_set_server_verifier(config_builder,
# server_cert_verifier);
# }
# else if(getenv("CA_FILE")) {
# server_cert_root_store_builder = rustls_root_cert_store_builder_new();
# result = rustls_root_cert_store_builder_load_roots_from_file(
# server_cert_root_store_builder, getenv("CA_FILE"), true);
# if(result != RUSTLS_RESULT_OK) {
# print_error("loading trusted certificates", result);
# goto cleanup;
# }
# result = rustls_root_cert_store_builder_build(
# server_cert_root_store_builder, &server_cert_root_store);
# if(result != RUSTLS_RESULT_OK) {
# goto cleanup;
# }
# server_cert_verifier_builder =
# rustls_web_pki_server_cert_verifier_builder_new(server_cert_root_store);

# result = rustls_web_pki_server_cert_verifier_builder_build(
# server_cert_verifier_builder, &server_cert_verifier);
# if(result != RUSTLS_RESULT_OK) {
# goto cleanup;
# }
# rustls_client_config_builder_set_server_verifier(config_builder,
# server_cert_verifier);
# }
# else if(getenv("NO_CHECK_CERTIFICATE")) {
# rustls_client_config_builder_dangerous_set_certificate_verifier(
# config_builder, verify);
# }
# else {
# fprintf(stderr,
# "client: must set either RUSTLS_PLATFORM_VERIFIER or CA_FILE or "
# "NO_CHECK_CERTIFICATE env var\n");
# goto cleanup;
# }

# char *auth_cert = getenv("AUTH_CERT");
# char *auth_key = getenv("AUTH_KEY");
# if((auth_cert && !auth_key) || (!auth_cert && auth_key)) {
# fprintf(
# stderr,
# "client: must set both AUTH_CERT and AUTH_KEY env vars, or neither\n");
# goto cleanup;
# }
# else if(auth_cert && auth_key) {
# certified_key = load_cert_and_key(auth_cert, auth_key);
# if(certified_key == NULL) {
# goto cleanup;
# }
# rustls_client_config_builder_set_certified_key(
# config_builder, &certified_key, 1);
# }

# rustls_client_config_builder_set_alpn_protocols(
# config_builder, &alpn_http11, 1);

# result = rustls_client_config_builder_build(config_builder, &client_config);
# if(result != RUSTLS_RESULT_OK) {
# print_error("building client config", result);
# goto cleanup;
# }

# int i;
# for(i = 0; i < 3; i++) {
# result = do_request(client_config, hostname, port, path);
# if(result != 0) {
# goto cleanup;
# }
# }

# // Success!
# ret = 0;

# cleanup:
# rustls_root_cert_store_builder_free(server_cert_root_store_builder);
# rustls_root_cert_store_free(server_cert_root_store);
# rustls_web_pki_server_cert_verifier_builder_free(
# server_cert_verifier_builder);
# rustls_server_cert_verifier_free(server_cert_verifier);
# rustls_certified_key_free(certified_key);
# rustls_client_config_free(client_config);
# rustls_crypto_provider_free(custom_provider);

11 changes: 9 additions & 2 deletions mojoproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
[project]
authors = ["Mikhail Tavarez <[email protected]>"]
channels = ["conda-forge", "https://conda.modular.com/max", "file:////Users/mikhailtavarez/.rattler/output"]
channels = [
"conda-forge",
"https://conda.modular.com/max",
"https://repo.prefix.dev/mojo-community",
]
description = "Add a short description here"
name = "mojo-rustls"
platforms = ["osx-arm64"]
version = "0.1.0"
version = "0.1.1"

[tasks]
tests = "bash scripts/tests.sh"
Expand All @@ -14,3 +18,6 @@ publish = { cmd = "bash scripts/publish.sh", env = { PREFIX_API_KEY = "$PREFIX_A

[dependencies]
max = ">=24.5.0,<25"
# mojo-rustls = ">=0.1.1,<0.2" # self dependency just for local testing
gojo = ">=0.1.9,<0.2"
lightbug_http = "0.1.6"
21 changes: 21 additions & 0 deletions output/bld/rattler-build_mojo-rustls-ffi_1726516062/work/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Mikhail Tavarez

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
export CONDA_BUILD_STATE="BUILD"
export PKG_CONFIG_PATH="/Users/lukas/dev/mojo-rustls/output/bld/rattler-build_mojo-rustls-ffi_1726516062/host_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_place/lib/pkgconfig"
export CMAKE_GENERATOR="Unix Makefiles"
export PIP_NO_DEPENDENCIES="True"
export MAKE_TERMOUT="1"
export GCC_COLORS="error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01"
export PKG_HASH="h60d57d3"
export PREFIX="/Users/lukas/dev/mojo-rustls/output/bld/rattler-build_mojo-rustls-ffi_1726516062/host_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_place"
export PKG_NAME="mojo-rustls-ffi"
export CLICOLOR_FORCE="1"
export build_platform="osx-arm64"
export PATH="/Users/lukas/dev/mojo-rustls/.magic/envs/default/bin:/Users/lukas/.modular/bin:/nix/var/nix/profiles/default/bin:/Users/lukas/.modular/pkg/packages.modular.com_nightly_max/bin:/Users/lukas/.bin:/Users/lukas/.cargo/bin:/opt/homebrew/opt/llvm/bin:/Users/lukas/.modular/pkg/packages.modular.com_nightly_mojo/bin:/Users/lukas/.nix-profile/bin:/Users/lukas/.modular/pkg/packages.modular.com_mojo/bin:/opt/homebrew/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/MacGPG2/bin:/Applications/Ghostty.app/Contents/MacOS"
export BUILD="arm64-apple-darwin20.0.0"
export CMAKE_COLOR_DIAGNOSTICS="ON"
export PKG_BUILD_STRING="h60d57d3_0"
export CONDA_BUILD="1"
export PKG_VERSION="0.1.0"
export SUBDIR="osx-arm64"
export SOURCE_DATE_EPOCH="1726516062"
export PYTHONNOUSERSITE="1"
export AM_COLOR_TESTS="always"
export LANG="en_US.UTF-8"
export SHLIB_EXT=".dylib"
export HOME="/Users/lukas"
export PIP_CACHE_DIR="/Users/lukas/dev/mojo-rustls/output/bld/rattler-build_mojo-rustls-ffi_1726516062/pip_cache"
export LC_ALL="en_US.UTF-8"
export FORCE_COLOR="1"
export SRC_DIR="/Users/lukas/dev/mojo-rustls/output/bld/rattler-build_mojo-rustls-ffi_1726516062/work"
export NPY_DISTUTILS_APPEND_FLAGS="1"
export BUILD_PREFIX="/Users/lukas/dev/mojo-rustls/output/bld/rattler-build_mojo-rustls-ffi_1726516062/build_env"
export MAKEFLAGS=""
export PIP_NO_BUILD_ISOLATION="False"
export CPU_COUNT="16"
export PIP_IGNORE_INSTALLED="True"
export OSX_ARCH="arm64"
export target_platform="osx-arm64"
export PIP_NO_INDEX="True"
export SSL_CERT_FILE=""
export CONDA_DEFAULT_ENV="/Users/lukas/dev/mojo-rustls/output/bld/rattler-build_mojo-rustls-ffi_1726516062/host_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_place"
export RECIPE_DIR="/Users/lukas/dev/mojo-rustls/src"
export MACOSX_DEPLOYMENT_TARGET="11.0"
export PYTHON="/Users/lukas/dev/mojo-rustls/output/bld/rattler-build_mojo-rustls-ffi_1726516062/host_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_place/bin/python"
export PKG_BUILDNUM="0"
export CONDA_BUILD_CROSS_COMPILATION="0"
export BUILD_DIR="/Users/lukas/dev/mojo-rustls/output/bld/rattler-build_mojo-rustls-ffi_1726516062"
export ARCH="arm64"

export PATH="/Users/lukas/dev/mojo-rustls/output/bld/rattler-build_mojo-rustls-ffi_1726516062/host_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_place/bin:/Users/lukas/.modular/bin:/nix/var/nix/profiles/default/bin:/Users/lukas/.modular/pkg/packages.modular.com_nightly_max/bin:/Users/lukas/.bin:/Users/lukas/.cargo/bin:/opt/homebrew/opt/llvm/bin:/Users/lukas/.modular/pkg/packages.modular.com_nightly_mojo/bin:/Users/lukas/.nix-profile/bin:/Users/lukas/.modular/pkg/packages.modular.com_mojo/bin:/opt/homebrew/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/MacGPG2/bin:/Applications/Ghostty.app/Contents/MacOS"
export CONDA_PREFIX="/Users/lukas/dev/mojo-rustls/output/bld/rattler-build_mojo-rustls-ffi_1726516062/host_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_place"

export PATH="/Users/lukas/dev/mojo-rustls/output/bld/rattler-build_mojo-rustls-ffi_1726516062/build_env/bin:/Users/lukas/dev/mojo-rustls/output/bld/rattler-build_mojo-rustls-ffi_1726516062/host_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_place/bin:/Users/lukas/.modular/bin:/nix/var/nix/profiles/default/bin:/Users/lukas/.modular/pkg/packages.modular.com_nightly_max/bin:/Users/lukas/.bin:/Users/lukas/.cargo/bin:/opt/homebrew/opt/llvm/bin:/Users/lukas/.modular/pkg/packages.modular.com_nightly_mojo/bin:/Users/lukas/.nix-profile/bin:/Users/lukas/.modular/pkg/packages.modular.com_mojo/bin:/opt/homebrew/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/MacGPG2/bin:/Applications/Ghostty.app/Contents/MacOS"
export CONDA_PREFIX="/Users/lukas/dev/mojo-rustls/output/bld/rattler-build_mojo-rustls-ffi_1726516062/build_env"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

## Start of bash preamble
if [ -z ${CONDA_BUILD+x} ]; then
source /Users/lukas/dev/mojo-rustls/output/bld/rattler-build_mojo-rustls-ffi_1726516062/work/build_env.sh
fi
# enable debug mode for the rest of the script
set -x
## End of preamble

mkdir -p ${PREFIX}/share/mojo-rustls-ffi
git clone --depth=1 [email protected]:rustls/rustls-ffi.git
cd rustls-ffi && cargo cinstall --library-type=cdylib --destdir=${PREFIX}/share/mojo-rustls-ffi/librustls.dylib
cd .. && rm -R rustls-ffi
Submodule rustls-ffi added at 326bb7
21 changes: 21 additions & 0 deletions output/bld/rattler-build_mojo-rustls-ffi_1726516100/work/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Mikhail Tavarez

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading
Loading