diff --git a/content/themis/languages/nodejs/installation.md b/content/themis/languages/nodejs/installation.md index 0d7f3712..2f012188 100644 --- a/content/themis/languages/nodejs/installation.md +++ b/content/themis/languages/nodejs/installation.md @@ -226,3 +226,64 @@ Error: Key Pair generation failed: invalid parameter code: 12 } ``` + +### Verified example how to fix it. +You need to install `OpenSSL` and `Themis` native library from the source code and install the `jsthemis` package. +This is a source code of Dockerfile. You may copy and build, and run it. +```Dockerfile +FROM ubuntu:22.04 + +RUN apt update +RUN apt install -y git wget npm gcc make tar + +ARG OPENSSL_VERSION=3.0.10 +ARG OPENSSL_PREFIX=/opt/openssl-${OPENSSL_VERSION} + +RUN wget https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz && \ + apt purge -y openssl && \ + mkdir ${OPENSSL_PREFIX} -p && \ + tar xf openssl-${OPENSSL_VERSION}.tar.gz && \ + cd openssl-${OPENSSL_VERSION} && \ + ./Configure --prefix=${OPENSSL_PREFIX} && \ + make && \ + make install + +RUN apt install -y npm +RUN npm install -g n +RUN n lts + +ENV LD_LIBRARY_PATH=${OPENSSL_PREFIX}/lib64 +ENV PKG_CONFIG_PATH=${OPENSSL_PREFIX}/lib64/pkgconfig +ENV PATH=${OPENSSL_PREFIX}/bin:${PATH} + +RUN git clone https://github.com/cossacklabs/themis.git && \ + cd themis && \ + make ENGINE_INCLUDE_PATH=${OPENSSL_PREFIX}/include ENGINE_LIB_PATH=${OPENSSL_PREFIX}/lib64 && \ + make install + +WORKDIR /jsthemis +RUN npm init -y -f && npm install jsthemis +RUN echo "const themis = require('jsthemis');" >> index.js \ + && echo "let keypair = new themis.KeyPair();" >> index.js \ + && echo "" >> index.js \ + && echo "// Keys are Buffers" >> index.js \ + && echo "let privateKey = keypair.private();" >> index.js \ + && echo "let publicKey = keypair.public();" >> index.js \ + && echo "let masterKey = new themis.SymmetricKey();" >> index.js \ + && echo "" >> index.js \ + && echo "console.log(privateKey);" >> index.js \ + && echo "console.log(publicKey);" >> index.js \ + && echo "console.log(masterKey);" >> index.js + +ENTRYPOINT ["node", "index.js"] +``` + +As a result you will see similar three lines of keys: private, public and symmetric keys. +``` + + + +``` +If you see something similar, then you have done everything right and can transfer this recipe for installing `jsthemis` to your system. +If you see an error, please create an issue on GitHub and we will try to help you. +