Skip to content

Instantly share code, notes, and snippets.

@junaruga
Last active August 4, 2025 18:42
Show Gist options
  • Select an option

  • Save junaruga/b1289eead744a5fe68910e151620300c to your computer and use it in GitHub Desktop.

Select an option

Save junaruga/b1289eead744a5fe68910e151620300c to your computer and use it in GitHub Desktop.
#!/bin/bash
set -ex
OPENSSL_DIR="/home/jaruga/git/openssl/dist"
RUBY_OPENSSL_DIR="/home/jaruga/git/ruby/openssl"
git clean -fdx
./Configure \
--prefix="${OPENSSL_DIR}" \
--libdir=lib \
--debug \
shared \
enable-fips \
enable-trace \
'-Wl,-rpath,$(LIBRPATH)' \
no-docs \
-O0 -g3 -ggdb3 -gdwarf-5
make -j8
make install
sed -e "s|OPENSSL_DIR|$OPENSSL_DIR|" "${RUBY_OPENSSL_DIR}/tool/openssl_fips.cnf.tmpl" \
> "${OPENSSL_DIR}/ssl/openssl_fips.cnf"
OPENSSL_CONF="$OPENSSL_DIR/ssl/openssl_fips.cnf" \
"${OPENSSL_DIR}/bin/openssl" list -providers
pushd "${RUBY_OPENSSL_DIR}"
bundle exec rake clean
rm -rf tmp/ lib/openssl.so
MAKEFLAGS="V=1" \
RUBY_OPENSSL_EXTCFLAGS="-O0 -g3 -ggdb3 -gdwarf-5" \
bundle exec rake compile -- \
--with-openssl-dir="${OPENSSL_DIR}"
OPENSSL_CONF="$OPENSSL_DIR/ssl/openssl_fips.cnf" \
bundle exec rake debug
OPENSSL_CONF="$OPENSSL_DIR/ssl/openssl_fips.cnf" \
bundle exec ruby -I./lib test.rb
popd
require 'openssl'
key_data = <<~EOF
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIP+TT0V8Fndsnacji9tyf6hmhHywcOWTee9XkiBeJoVloAoGCCqGSM49
AwEHoUQDQgAEBkhhJIU/2/YdPSlY2I1k25xjK4trr5OXSgXvBC21PtY0HQ7lor7A
jzT0giJITqmcd81fwGw5+96zLcdxTF1hVQ==
-----END EC PRIVATE KEY-----
EOF
OpenSSL::PKey.read(key_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment