code: static long toBIO(ByteBufAllocator allocator, PrivateKey key) throws Exception {
          if (key == null) {
              return 0;
          }
  
          PemEncoded pem = PemPrivateKey.toPEM(allocator, true, key);
          try {
              return toBIO(allocator, pem.retain());
          } finally {
              pem.release();
          }
      }
docs: Return the pointer to a <a href="https://www.openssl.org/docs/crypto/BIO_get_mem_ptr.html">in-memory BIO</a>
  or {@code 0} if the {@code key} is {@code null}. The BIO contains the content of the {@code key}.