openssl-wasm
What is this?
This repository holds the source files and generated WebAssembly (WASM) output for OpenSSL compiled to WASM.
Versioning
The versions here are linked to OpenSSL versions, so if you require('openssl-wasm')
and get OpenSSL 3.1.0
, but you want OpenSSL 1.1.1
then you should install that with npm install openssl-wasm@1.1.1
Getting Started
The following assumes that you are working in a bash
terminal with docker
installed and available.
- Build the
openssl-wasm
docker image- Run
./src/build-image.sh
- The image expects a volume to be mounted at
/WASM
- Run
- Build a specific version of OpenSSL
- Run
docker run openssl-wasm OpenSSL_1_1_1-stable
if you want to buildOpenSSL_1_1_1-stable
- You can use any tag or branch from the OpenSSL GitHub repo
- Run
- Build all OpenSSL tags and branches
- Run
./src/build-all-tags.sh
- It takes a while
- Run
How does it work?
tldr; it uses empscripten
to build the specified OpenSSL tag or branch in a container, and the WASM output is written to a mounted volume (a local folder).
- The
Dockerfile
- Installs dependencies
- Installs
emscripten
SDK (emsdk
) - Clones the OpenSSL repo into the image
- Copies the build script (
./src/docker/emscripten.sh
) on build
- The
openssl-wasm
image- Will
git checkout
the given a tag or branch name - Configure
emsdk
and build tooling - Builds OpenSSL using
emmake make
- Copies the output to the mounted volume/folder
- Will
- The
*.wasm
output- Should be copied to a local folder
- Should have an
openssl.js
file (Module) to load the WebAssembly - Should have an
openssl.wasm
file which is the WebAssembly version of OpenSSL