OpenSSL::Bio::BIO_new_mem_buf does not copy its first argument, the
buffer to read the key from. Instead it keeps a pointer to that buffer. The
returned BIO struct contains said pointer. It is thus important to make
sure that that first argument is not GCed until that BIO struct is also out
of use. Other wise it can happen, that the buffer is freed by the Raku GC
and SSL functions that try to read that BIO receive garbage and thus fail
to successfully create a key.
Thanks to @niner for guiding me through debugging at the MoarVM level.
OpenSSL::Bio::BIO_new_mem_buf
does not copy its first argument, the buffer to read the key from. Instead it keeps a pointer to that buffer. The returned BIO struct contains said pointer. It is thus important to make sure that that first argument is not GCed until that BIO struct is also out of use. Other wise it can happen, that the buffer is freed by the Raku GC and SSL functions that try to read that BIO receive garbage and thus fail to successfully create a key.Thanks to @niner for guiding me through debugging at the MoarVM level.