OpenSSL::PKey

Hello everyone!

I’ve been trying to port a Ruby application to Crystal (and so far I’m absolutely excited about Crystal). With a lot of trial and error, I’ve got most of the things already running, but I’m absolutely lost when it comes to OpenSSL. I can’t figure out how to call anything related to OpenSSL::PKey. It’s sadly also missing in the documentation (but to be fair it’s not the first thing I’ve been missing there, but the other things just worked the same way as in Ruby anyway, but that’s not the case for PKey).

Thanks in advance!

Hi!

OpenSSL is probably the roughest part in Crystal. I think we mapped the things we need to be able to do HTTPS, but not much more.

So two options to move forward with this:

  • The core team prioritizes doing this
  • Someone contributes this to the standard library

I think you already decided to not use Crystal and use Swift, and that’s totally fine too! Crystal isn’t well suited for this particular task at the moment, just because there’s no code around that yet.

4 Likes

Thanks for the reply. Yeah, sadly my current project is using Swift now. But I will for sure keep an eye on Crystal :slightly_smiling_face:

As someone else might have the same problem - here is a potential solution:

I have received a hint regarding a shard called OpenSSL_ext. Don’t know if my version was just way too old or if it’s for a different reason, but I ran into some unresolved symbols (actually just one - this was included in my older OpenSSL library, but not in the newer one). But this was easy to fix: the symbol was EVP_PKey_size (or something like that - it’s simply the one the compiler complains about) but it should be …get_size (so insert the “_get” before the size). And then it just works the way one would expect it (at least it included what I would have needed, don’t know if or how complete it is). Hope this helps!