@@ -126,11 +126,41 @@ const char *SSL_error_string(int ssl_error, int orig_ret)
126
126
127
127
SSL* SSL_new_client ()
128
128
{
129
+ if (access (tls_cert_name, F_OK) == 0 && access (tls_key_name, F_OK) == 0 ) {
130
+ if (SSL_CTX_use_certificate_file (sip_trp_ssl_ctx_client,
131
+ tls_cert_name,
132
+ SSL_FILETYPE_PEM) != 1 ) {
133
+ ERROR (" TLS_init_context: SSL_CTX_use_certificate_file (client) failed" );
134
+ return NULL ;
135
+ }
136
+ if (SSL_CTX_use_PrivateKey_file (sip_trp_ssl_ctx_client,
137
+ tls_key_name,
138
+ SSL_FILETYPE_PEM) != 1 ) {
139
+ ERROR (" TLS_init_context: SSL_CTX_use_PrivateKey_file (client) failed" );
140
+ return NULL ;
141
+ }
142
+ }
143
+
129
144
return SSL_new (sip_trp_ssl_ctx_client);
130
145
}
131
146
132
147
SSL* SSL_new_server ()
133
148
{
149
+
150
+ if (SSL_CTX_use_certificate_file (sip_trp_ssl_ctx,
151
+ tls_cert_name,
152
+ SSL_FILETYPE_PEM) != 1 ) {
153
+ ERROR (" SSL_new_server: SSL_CTX_use_certificate_file failed" );
154
+ return NULL ;
155
+ }
156
+
157
+ if (SSL_CTX_use_PrivateKey_file (sip_trp_ssl_ctx,
158
+ tls_key_name,
159
+ SSL_FILETYPE_PEM) != 1 ) {
160
+ ERROR (" SSL_new_server: SSL_CTX_use_PrivateKey_file failed" );
161
+ return NULL ;
162
+ }
163
+
134
164
return SSL_new (sip_trp_ssl_ctx);
135
165
}
136
166
@@ -332,38 +362,6 @@ enum tls_init_status TLS_init_context(void)
332
362
passwd_call_back_routine);
333
363
SSL_CTX_set_default_passwd_cb (sip_trp_ssl_ctx_client,
334
364
passwd_call_back_routine);
335
-
336
- if (SSL_CTX_use_certificate_file (sip_trp_ssl_ctx,
337
- tls_cert_name,
338
- SSL_FILETYPE_PEM) != 1 ) {
339
- char errbuf[256 ] = {' \0 ' };
340
- ERR_error_string_n (ERR_get_error (), errbuf, sizeof (errbuf));
341
- ERROR (" TLS_init_context: SSL_CTX_use_certificate_file failed: %s" , errbuf);
342
- return TLS_INIT_ERROR;
343
- }
344
-
345
- if (SSL_CTX_use_certificate_file (sip_trp_ssl_ctx_client,
346
- tls_cert_name,
347
- SSL_FILETYPE_PEM) != 1 ) {
348
- char errbuf[256 ] = {' \0 ' };
349
- ERR_error_string_n (ERR_get_error (), errbuf, sizeof (errbuf));
350
- ERROR (" TLS_init_context: SSL_CTX_use_certificate_file (client) failed: %s" , errbuf);
351
- return TLS_INIT_ERROR;
352
- }
353
- if (SSL_CTX_use_PrivateKey_file (sip_trp_ssl_ctx,
354
- tls_key_name,
355
- SSL_FILETYPE_PEM) != 1 ) {
356
- ERROR (" TLS_init_context: SSL_CTX_use_PrivateKey_file failed" );
357
- return TLS_INIT_ERROR;
358
- }
359
-
360
- if (SSL_CTX_use_PrivateKey_file (sip_trp_ssl_ctx_client,
361
- tls_key_name,
362
- SSL_FILETYPE_PEM) != 1 ) {
363
- ERROR (" TLS_init_context: SSL_CTX_use_PrivateKey_file (client) failed" );
364
- return TLS_INIT_ERROR;
365
- }
366
-
367
365
return TLS_INIT_NORMAL;
368
366
}
369
367
0 commit comments