从我收集的内容中读取OpenSSL wiki页面,我生成Diffie-Hellman密钥的代码是正确的。但它在最后一步失败了 - EVP_PKEY_keygen()。
除了通过/失败之外,有没有办法获得更详细的信息?甚至可能是它失败的原因?
答案 0 :(得分:0)
Here's how to get more detailed information out of OpenSSL errors. It's minimal but generally helpful.
#include <openssl/err.h>
// Do this during construction or initialization
ERR_load_crypto_strings();
// Do this when an error occurs
unsigned long error = ERR_get_error();
cout << "Error code = " << error << std::endl;
cout << ERR_reason_error_string(error) << std::endl;
// Do this when shutting down
ERR_free_strings();