On 25/05/14 14:40, Mody, Darshan (Darshan) wrote:
> I use below command
>
> openssl ecparam -out key.pem -name prime256v1 -genkey. I am using another 3rd
> Party tool SIPp. Below is the method that sets the SSL CTX
>
Whilst I don't think its the cause of your problem, I would suggest
adding -noout to the above command (prevents both the parameters and the
key being written out separately to the key file, which is probably not
what you intended).
I took your code and stripped it down to just the code to load the
private key. I also created a key file using the command line you
provided. My code below.
This works fine. What error are you seeing, and what version of openssl
are you using.
Matt
#include <openssl/ssl.h>
#define ERROR printf
#define SSL_INIT_ERROR -1
#define SSL_INIT_NORMAL 0
typedef int ssl_init_status;
static char *tls_key_name = "key.pem";
ssl_init_status FI_init_ssl_context (void)
{
SSL_CTX *sip_trp_ssl_ctx;
sip_trp_ssl_ctx = SSL_CTX_new( TLSv1_method() );
if ( sip_trp_ssl_ctx == NULL ) {
ERROR("FI_init_ssl_context: SSL_CTX_new with TLSv1_method failed");
return SSL_INIT_ERROR;
}
if ( SSL_CTX_use_PrivateKey_file(sip_trp_ssl_ctx,
tls_key_name,
SSL_FILETYPE_PEM ) != 1 ) {
ERROR("FI_init_ssl_context: SSL_CTX_use_PrivateKey_file failed");
return SSL_INIT_ERROR;
}
printf("Success\n");
return SSL_INIT_NORMAL;
}
int main(void)
{
ssl_init_status ret;
SSL_load_error_strings();
OpenSSL_add_ssl_algorithms();
ret = FI_init_ssl_context();
}
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [email protected]
Automated List Manager [email protected]