]> git.sur5r.net Git - openldap/blob - libraries/libldap/tls.c
Changed ldap_pvt_tls_init_def_ctx() to not fail if there is no cacertfile/dir specifi...
[openldap] / libraries / libldap / tls.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  *
6  * tls.c - Handle tls/ssl using SSLeay or OpenSSL.
7  */
8
9 #include "portable.h"
10
11 #ifdef HAVE_TLS
12
13 #include <stdio.h>
14
15 #include <ac/stdlib.h>
16 #include <ac/errno.h>
17 #include <ac/socket.h>
18 #include <ac/string.h>
19 #include <ac/time.h>
20 #include <ac/unistd.h>
21
22 #include "ldap-int.h"
23
24 #ifdef LDAP_R_COMPILE
25 #include <ldap_pvt_thread.h>
26 #endif
27
28 #ifdef HAVE_OPENSSL_SSL_H
29 #include <openssl/ssl.h>
30 #elif defined( HAVE_SSL_H )
31 #include <ssl.h>
32 #endif
33
34 static int  tls_opt_trace = 1;
35 static char *tls_opt_certfile = NULL;
36 static char *tls_opt_keyfile = NULL;
37 static char *tls_opt_cacertfile = NULL;
38 static char *tls_opt_cacertdir = NULL;
39 static int  tls_opt_require_cert = 0;
40 static char *tls_opt_ciphersuite = NULL;
41
42 #define HAS_TLS( sb ) ((sb)->sb_io==&tls_io)
43
44 static int tls_setup( Sockbuf *sb, void *arg );
45 static int tls_remove( Sockbuf *sb );
46 static ber_slen_t tls_read( Sockbuf *sb, void *buf, ber_len_t len );
47 static ber_slen_t tls_write( Sockbuf *sb, void *buf, ber_len_t len );
48 static int tls_close( Sockbuf *sb );
49 static int tls_report_error( void );
50
51 static Sockbuf_IO tls_io=
52 {
53    tls_setup,
54    tls_remove,
55    tls_read,
56    tls_write,
57    tls_close
58 };
59
60 static void tls_info_cb( SSL *ssl, int where, int ret );
61 static int tls_verify_cb( int ok, X509_STORE_CTX *ctx );
62 static RSA * tls_tmp_rsa_cb( SSL *ssl, int is_export, int key_length );
63 static DH * tls_tmp_dh_cb( SSL *ssl, int is_export, int key_length );
64 static STACK_OF(X509_NAME) * get_ca_list( char * bundle, char * dir );
65
66 static SSL_CTX *tls_def_ctx = NULL;
67
68 #ifdef LDAP_R_COMPILE
69 /*
70  * provide mutexes for the SSLeay library.
71  */
72 static ldap_pvt_thread_mutex_t  tls_mutexes[CRYPTO_NUM_LOCKS];
73
74 static void tls_locking_cb( int mode, int type, const char *file, int line )
75 {
76         if ( mode & CRYPTO_LOCK ) {
77                 ldap_pvt_thread_mutex_lock( tls_mutexes+type );
78         } else {
79                 ldap_pvt_thread_mutex_unlock( tls_mutexes+type );
80         }
81 }
82
83 /*
84  * an extra mutex for the default ctx.
85  */
86
87 static ldap_pvt_thread_mutex_t tls_def_ctx_mutex;
88
89 static void tls_init_threads( void )
90 {
91         int i;
92
93         for( i=0; i< CRYPTO_NUM_LOCKS ; i++ ) {
94                 ldap_pvt_thread_mutex_init( tls_mutexes+i );
95         }
96         CRYPTO_set_locking_callback( tls_locking_cb );
97         /* FIXME: the thread id should be added somehow... */
98
99         ldap_pvt_thread_mutex_init( &tls_def_ctx_mutex );
100 }
101 #endif /* LDAP_R_COMPILE */
102
103 /*
104  * Initialize tls system. Should be called only once.
105  */
106 int
107 ldap_pvt_tls_init( void )
108 {
109         static int tls_initialized = 0;
110
111         if ( tls_initialized )
112                 return -1;
113 #ifdef LDAP_R_COMPILE
114         tls_init_threads();
115 #endif
116         SSL_load_error_strings();
117         SSLeay_add_ssl_algorithms();
118         /* FIXME: mod_ssl does this */
119         X509V3_add_standard_extensions();
120         return 0;
121 }
122
123 /*
124  * initialize the default context
125  */
126 int
127 ldap_pvt_tls_init_def_ctx( void )
128 {
129         STACK_OF(X509_NAME) *calist;
130
131 #ifdef LDAP_R_COMPILE
132         ldap_pvt_thread_mutex_lock( &tls_def_ctx_mutex );
133 #endif
134         if ( tls_def_ctx == NULL ) {
135                 tls_def_ctx = SSL_CTX_new( SSLv23_method() );
136                 if ( tls_def_ctx == NULL ) {
137                         Debug( LDAP_DEBUG_ANY,
138                                "TLS: could not allocate default ctx.\n",0,0,0);
139                         goto error_exit;
140                 }
141                 if ( tls_opt_ciphersuite &&
142                      !SSL_CTX_set_cipher_list( tls_def_ctx,
143                         tls_opt_ciphersuite ) ) {
144                         Debug( LDAP_DEBUG_ANY,
145                                "TLS: could not set cipher list %s.\n",
146                                tls_opt_ciphersuite, 0, 0 );
147                         tls_report_error();
148                         goto error_exit;
149                 }
150                 if (tls_opt_cacertfile != NULL || tls_opt_cacertdir != NULL) {
151                         if ( !SSL_CTX_load_verify_locations( tls_def_ctx,
152                                                              tls_opt_cacertfile,
153                                                              tls_opt_cacertdir )
154                              || !SSL_CTX_set_default_verify_paths( tls_def_ctx ) )
155                         {
156                                 Debug( LDAP_DEBUG_ANY,
157                         "TLS: could not load verify locations (file:`%s',dir:`%s').\n",
158                                        tls_opt_cacertfile,tls_opt_cacertdir,0);
159                                 tls_report_error();
160                                 goto error_exit;
161                         }
162                         calist = get_ca_list( tls_opt_cacertfile, tls_opt_cacertdir );
163                         if ( !calist ) {
164                                 Debug( LDAP_DEBUG_ANY,
165                         "TLS: could not load client CA list (file:`%s',dir:`%s').\n",
166                                        tls_opt_cacertfile,tls_opt_cacertdir,0);
167                                 tls_report_error();
168                                 goto error_exit;
169                         }
170                         SSL_CTX_set_client_CA_list( tls_def_ctx, calist );
171                 }
172                 if ( tls_opt_keyfile &&
173                      !SSL_CTX_use_PrivateKey_file( tls_def_ctx,
174                                                    tls_opt_keyfile,
175                                                    SSL_FILETYPE_PEM ) ) {
176                         Debug( LDAP_DEBUG_ANY,
177                                "TLS: could not use key file `%s'.\n",
178                                tls_opt_keyfile,0,0);
179                         tls_report_error();
180                         goto error_exit;
181                 }
182                 if ( tls_opt_certfile &&
183                      !SSL_CTX_use_certificate_file( tls_def_ctx,
184                                                     tls_opt_certfile,
185                                                     SSL_FILETYPE_PEM ) ) {
186                         Debug( LDAP_DEBUG_ANY,
187                                "TLS: could not use certificate `%s'.\n",
188                                tls_opt_certfile,0,0);
189                         tls_report_error();
190                         goto error_exit;
191                 }
192                 if ( ( tls_opt_certfile || tls_opt_keyfile ) &&
193                      !SSL_CTX_check_private_key( tls_def_ctx ) ) {
194                         Debug( LDAP_DEBUG_ANY,
195                                "TLS: private key mismatch.\n",
196                                0,0,0);
197                         tls_report_error();
198                         goto error_exit;
199                 }
200                 if ( tls_opt_trace ) {
201                         SSL_CTX_set_info_callback( tls_def_ctx, tls_info_cb );
202                 }
203                 SSL_CTX_set_verify( tls_def_ctx, (tls_opt_require_cert) ?
204                         (SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT) :
205                         SSL_VERIFY_PEER, tls_verify_cb );
206                 SSL_CTX_set_tmp_rsa_callback( tls_def_ctx, tls_tmp_rsa_cb );
207                 /* SSL_CTX_set_tmp_dh_callback( tls_def_ctx, tls_tmp_dh_cb ); */
208         }
209 #ifdef LDAP_R_COMPILE
210         ldap_pvt_thread_mutex_unlock( &tls_def_ctx_mutex );
211 #endif
212         return 0;
213 error_exit:
214 #ifdef LDAP_R_COMPILE
215         ldap_pvt_thread_mutex_unlock( &tls_def_ctx_mutex );
216 #endif
217         return -1;
218 }
219
220 static STACK_OF(X509_NAME) *
221 get_ca_list( char * bundle, char * dir )
222 {
223         STACK_OF(X509_NAME) *ca_list = NULL;
224
225         if ( bundle ) {
226                 ca_list = SSL_load_client_CA_file( bundle );
227         }
228         /*
229          * FIXME: We have now to go over all files in dir, load them
230          * and add every certificate there to ca_list.
231          */
232         return ca_list;
233 }
234
235 static SSL *
236 alloc_handle( Sockbuf *sb, void *ctx_arg )
237 {
238         int     err;
239         SSL_CTX *ctx;
240         SSL     *ssl;
241
242         if ( ctx_arg ) {
243                 ctx = (SSL_CTX *) ctx_arg;
244         } else {
245                 if ( ldap_pvt_tls_init_def_ctx() < 0 )
246                         return NULL;
247                 ctx = tls_def_ctx;
248         }
249
250         ssl = SSL_new( ctx );
251         if ( ssl == NULL ) {
252                 Debug( LDAP_DEBUG_ANY,"TLS: can't create ssl handle.\n",0,0,0);
253                 return NULL;
254         }
255
256         if ( tls_opt_trace ) {
257                 SSL_set_info_callback( ssl, tls_info_cb );
258         }
259         sb->sb_iodata = ssl;
260         SSL_set_fd( ssl, ber_pvt_sb_get_desc( sb ) );
261         return ssl;
262 }
263
264 static void
265 update_flags( Sockbuf *sb, SSL * ssl )
266 {
267         sb->sb_trans_needs_read  = (SSL_want_read(ssl) ? 1 : 0);
268         sb->sb_trans_needs_write = (SSL_want_write(ssl) ? 1 : 0);
269 }
270
271 /*
272  * Call this to do a TLS connect on a sockbuf. ctx_arg can be
273  * a SSL_CTX * or NULL, in which case the default ctx is used.
274  *
275  * Return value:
276  *
277  *  0 - Success. Connection is ready for communication.
278  * <0 - Error. Can't create a TLS stream.
279  * >0 - Partial success.
280  *        Do a select (using information from lber_pvt_sb_needs_{read,write}
281  *              and call again.
282  */
283
284 int
285 ldap_pvt_tls_connect( Sockbuf *sb, void *ctx_arg )
286 {
287         int     err;
288         SSL     *ssl;
289
290         if ( HAS_TLS( sb ) ) {
291                 ssl = (SSL *) sb->sb_iodata;
292         } else {
293                 ssl = alloc_handle( sb, ctx_arg );
294                 if ( ssl == NULL )
295                         return -1;
296                 ber_pvt_sb_clear_io( sb );
297                 ber_pvt_sb_set_io( sb, &tls_io, (void *)ssl );
298         }
299
300         err = SSL_connect( ssl );
301
302         if ( err <= 0 ) {
303                 if (
304 #ifdef EWOULDBLOCK
305                     (errno==EWOULDBLOCK) ||
306 #endif
307 #ifdef EAGAIN
308                     (errno==EAGAIN) ||
309 #endif
310                     (0)) {
311                         update_flags( sb, ssl );
312                         return 1;
313                 }
314                 Debug( LDAP_DEBUG_ANY,"TLS: can't connect.\n",0,0,0);
315                 ber_pvt_sb_clear_io( sb );
316                 ber_pvt_sb_set_io( sb, &ber_pvt_sb_io_tcp, NULL );
317                 return -1;
318         }
319         return 0;
320 }
321
322 /*
323  * Call this to do a TLS accept on a sockbuf.
324  * Everything else is the same as with tls_connect.
325  */
326 int
327 ldap_pvt_tls_accept( Sockbuf *sb, void *ctx_arg )
328 {
329         int     err;
330         SSL     *ssl;
331
332         if ( HAS_TLS( sb ) ) {
333                 ssl = (SSL *) sb->sb_iodata;
334         } else {
335                 ssl = alloc_handle( sb, ctx_arg );
336                 if ( ssl == NULL )
337                         return -1;
338                 ber_pvt_sb_clear_io( sb );
339                 ber_pvt_sb_set_io( sb, &tls_io, (void *)ssl );
340         }
341
342         err = SSL_accept( ssl );
343
344         if ( err <= 0 ) {
345                 if ( !SSL_want_nothing( ssl ) ) {
346                         update_flags( sb, ssl );
347                         return 1;
348                 }
349                 Debug( LDAP_DEBUG_ANY,"TLS: can't accept.\n",0,0,0 );
350                 tls_report_error();
351                 ber_pvt_sb_clear_io( sb );
352                 ber_pvt_sb_set_io( sb, &ber_pvt_sb_io_tcp, NULL );
353                 return -1;
354         }
355         return 0;
356 }
357
358 const char *
359 ldap_pvt_tls_get_peer( LDAP *ld )
360 {
361 }
362
363 const char *
364 ldap_pvt_tls_get_peer_issuer( LDAP *ld )
365 {
366 }
367
368 int
369 ldap_pvt_tls_config( struct ldapoptions *lo, int option, const char *arg )
370 {
371         int i;
372
373         switch( option ) {
374         case LDAP_OPT_X_TLS_CACERTFILE:
375         case LDAP_OPT_X_TLS_CACERTDIR:
376         case LDAP_OPT_X_TLS_CERTFILE:
377         case LDAP_OPT_X_TLS_KEYFILE:
378                 return ldap_pvt_tls_set_option( NULL, option, (void *) arg );
379         case LDAP_OPT_X_TLS_REQUIRE_CERT:
380                 i = ( ( strcasecmp( arg, "on" ) == 0 ) ||
381                       ( strcasecmp( arg, "yes" ) == 0) ||
382                       ( strcasecmp( arg, "true" ) == 0 ) );
383                 return ldap_pvt_tls_set_option( NULL, option, (void *) &i );
384         case LDAP_OPT_X_TLS:
385                 i = -1;
386                 if ( strcasecmp( arg, "never" ) == 0 )
387                         i = LDAP_OPT_X_TLS_NEVER ;
388                 if ( strcasecmp( arg, "demand" ) == 0 )
389                         i = LDAP_OPT_X_TLS_DEMAND ;
390                 if ( strcasecmp( arg, "allow" ) == 0 )
391                         i = LDAP_OPT_X_TLS_ALLOW ;
392                 if ( strcasecmp( arg, "try" ) == 0 )
393                         i = LDAP_OPT_X_TLS_TRY ;
394                 if ( strcasecmp( arg, "hard" ) == 0 )
395                         i = LDAP_OPT_X_TLS_HARD ;
396                 if (i >= 0)
397                         return ldap_pvt_tls_set_option( lo, option, &i );
398                 return -1;
399         default:
400                 return -1;
401         }
402 }
403
404 int
405 ldap_pvt_tls_get_option( struct ldapoptions *lo, int option, void *arg )
406 {
407         switch( option ) {
408         case LDAP_OPT_X_TLS:
409                 *(int *)arg = lo->ldo_tls_mode;
410                 break;
411         case LDAP_OPT_X_TLS_CERT:
412                 if ( lo == NULL )
413                         arg = (void *) tls_def_ctx;
414                 else
415                         arg = lo->ldo_tls_ctx;
416                 break;
417         case LDAP_OPT_X_TLS_CACERTFILE:
418                 *(char **)arg = tls_opt_cacertfile ?
419                         LDAP_STRDUP( tls_opt_cacertfile ) : NULL;
420                 break;
421         case LDAP_OPT_X_TLS_CACERTDIR:
422                 *(char **)arg = tls_opt_cacertdir ?
423                         LDAP_STRDUP( tls_opt_cacertdir ) : NULL;
424                 break;
425         case LDAP_OPT_X_TLS_CERTFILE:
426                 *(char **)arg = tls_opt_certfile ?
427                         LDAP_STRDUP( tls_opt_certfile ) : NULL;
428                 break;
429         case LDAP_OPT_X_TLS_KEYFILE:
430                 *(char **)arg = tls_opt_keyfile ?
431                         LDAP_STRDUP( tls_opt_keyfile ) : NULL;
432                 break;
433         case LDAP_OPT_X_TLS_REQUIRE_CERT:
434                 *(int *)arg = tls_opt_require_cert;
435                 break;
436         default:
437                 return -1;
438         }
439         return 0;
440 }
441
442 int
443 ldap_pvt_tls_set_option( struct ldapoptions *lo, int option, void *arg )
444 {
445         switch( option ) {
446         case LDAP_OPT_X_TLS:
447                 switch( *(int *) arg ) {
448                 case LDAP_OPT_X_TLS_NEVER:
449                 case LDAP_OPT_X_TLS_DEMAND:
450                 case LDAP_OPT_X_TLS_ALLOW:
451                 case LDAP_OPT_X_TLS_TRY:
452                 case LDAP_OPT_X_TLS_HARD:
453                         if (lo != NULL)
454                                 lo->ldo_tls_mode = *(int *)arg;
455                         return 0;
456                 default:
457                         return -1;
458                 }
459                 break;
460         case LDAP_OPT_X_TLS_CERT:
461                 if ( lo == NULL )
462                         tls_def_ctx = (SSL_CTX *) arg;
463                 else
464                         lo->ldo_tls_ctx = arg;
465                 break;
466         }
467         if ( lo != NULL )
468                 return -1;
469         switch( option ) {
470         case LDAP_OPT_X_TLS_CACERTFILE:
471                 if ( tls_opt_cacertfile ) free( tls_opt_cacertfile );
472                 tls_opt_cacertfile = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
473                 break;
474         case LDAP_OPT_X_TLS_CACERTDIR:
475                 if ( tls_opt_cacertdir ) free( tls_opt_cacertdir );
476                 tls_opt_cacertdir = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
477                 break;
478         case LDAP_OPT_X_TLS_CERTFILE:
479                 if ( tls_opt_certfile ) free( tls_opt_certfile );
480                 tls_opt_certfile = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
481                 break;
482         case LDAP_OPT_X_TLS_KEYFILE:
483                 if ( tls_opt_keyfile ) free( tls_opt_keyfile );
484                 tls_opt_keyfile = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
485                 break;
486         case LDAP_OPT_X_TLS_REQUIRE_CERT:
487                 tls_opt_require_cert = * (int *) arg;
488                 break;
489         case LDAP_OPT_X_TLS_CIPHER_SUITE:
490                 if ( tls_opt_ciphersuite ) free( tls_opt_ciphersuite );
491                 tls_opt_ciphersuite = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
492                 break;
493         default:
494                 return -1;
495         }
496         return 0;
497 }
498
499 static int
500 tls_setup( Sockbuf *sb, void *arg )
501 {
502         sb->sb_iodata = arg;
503         return 0;
504 }
505
506 static int
507 tls_remove( Sockbuf *sb )
508 {
509         SSL_free( (SSL *) sb->sb_iodata );
510         return 0;
511 }
512
513 static ber_slen_t
514 tls_write( Sockbuf *sb, void *buf, ber_len_t sz )
515 {
516         int ret = SSL_write( (SSL *)sb->sb_iodata, buf, sz );
517
518         update_flags(sb, (SSL *)sb->sb_iodata );
519 #ifdef WIN32
520         if (sb->sb_trans_needs_write)
521                 errno = EWOULDBLOCK;
522 #endif
523         return ret;
524 }
525
526 static ber_slen_t
527 tls_read( Sockbuf *sb, void *buf, ber_len_t sz )
528 {
529         int ret = SSL_read( (SSL *)sb->sb_iodata, buf, sz );
530
531         update_flags(sb, (SSL *)sb->sb_iodata );
532 #ifdef WIN32
533         if (sb->sb_trans_needs_read)
534                 errno = EWOULDBLOCK;
535 #endif
536         return ret;
537 }
538
539 static int
540 tls_close( Sockbuf *sb )
541 {
542         tcp_close( ber_pvt_sb_get_desc( sb ) );
543         return 0;
544 }
545
546 /* Derived from openssl/apps/s_cb.c */
547 static void
548 tls_info_cb( SSL *ssl, int where, int ret )
549 {
550         int w;
551         char *op;
552
553         w = where & ~SSL_ST_MASK;
554         if ( w & SSL_ST_CONNECT ) {
555                 op = "SSL_connect";
556         } else if ( w & SSL_ST_ACCEPT ) {
557                 op = "SSL_accept";
558         } else {
559                 op = "undefined";
560         }
561
562         if ( where & SSL_CB_LOOP ) {
563                 Debug( LDAP_DEBUG_TRACE,
564                        "TLS trace: %s:%s\n",
565                        op, SSL_state_string_long( ssl ), 0 );
566         } else if ( where & SSL_CB_ALERT ) {
567                 op = ( where & SSL_CB_READ ) ? "read" : "write";
568                 Debug( LDAP_DEBUG_TRACE,
569                        "TLS trace: SSL3 alert %s:%s:%s\n",
570                        op,
571                        SSL_alert_type_string_long( ret ),
572                        SSL_alert_desc_string_long( ret) );
573         } else if ( where & SSL_CB_EXIT ) {
574                 if ( ret == 0 ) {
575                         Debug( LDAP_DEBUG_TRACE,
576                                "TLS trace: %s:failed in %s\n",
577                                op, SSL_state_string_long( ssl ), 0 );
578                 } else if ( ret < 0 ) {
579                         Debug( LDAP_DEBUG_TRACE,
580                                "TLS trace: %s:error in %s\n",
581                                op, SSL_state_string_long( ssl ), 0 );
582                 }
583         }
584 }
585
586 static int
587 tls_verify_cb( int ok, X509_STORE_CTX *ctx )
588 {
589         X509 *cert;
590         int errnum;
591         int errdepth;
592         X509_NAME *subject;
593         X509_NAME *issuer;
594         char *sname;
595         char *iname;
596
597         cert = X509_STORE_CTX_get_current_cert( ctx );
598         errnum = X509_STORE_CTX_get_error( ctx );
599         errdepth = X509_STORE_CTX_get_error_depth( ctx );
600
601         /*
602          * X509_get_*_name return pointers to the internal copies of
603          * those things requested.  So do not free them.
604          */
605         subject = X509_get_subject_name( cert );
606         issuer = X509_get_issuer_name( cert );
607         /* X509_NAME_oneline, if passed a NULL buf, allocate memomry */
608         sname = X509_NAME_oneline( subject, NULL, 0 );
609         iname = X509_NAME_oneline( issuer, NULL, 0 );
610         Debug( LDAP_DEBUG_TRACE,
611                "TLS certificate verification: depth: %d, subject: %s, issuer: %s\n",
612                errdepth,
613                sname ? sname : "-unknown-",
614                iname ? iname : "-unknown-" );
615         if ( sname )
616                 free ( sname );
617         if ( iname )
618                 free ( iname );
619
620         return 1;
621 }
622
623 /* Inspired by ERR_print_errors in OpenSSL */
624 static int
625 tls_report_error( void )
626 {
627         unsigned long l;
628         char buf[200];
629         const char *file;
630         int line;
631
632         while ( ( l = ERR_get_error_line( &file, &line ) ) != 0 ) {
633                         Debug( LDAP_DEBUG_ANY, "TLS: %s %s:%d\n",
634                                ERR_error_string( l, buf ), file, line );
635         }
636 }
637
638 static RSA *
639 tls_tmp_rsa_cb( SSL *ssl, int is_export, int key_length )
640 {
641         RSA *tmp_rsa;
642
643         /* FIXME:  Pregenerate the key on startup */
644         /* FIXME:  Who frees the key? */
645         tmp_rsa = RSA_generate_key( key_length, RSA_F4, NULL, NULL );
646
647         if ( !tmp_rsa ) {
648                 Debug( LDAP_DEBUG_ANY, "TLS: Failed to generate temporary %d-bit %s RSA key\n",
649                        key_length, is_export ? "export" : "domestic", 0 );
650                 return NULL;
651         }
652         return tmp_rsa;
653 }
654
655 static DH *
656 tls_tmp_dh_cb( SSL *ssl, int is_export, int key_length )
657 {
658         return NULL;
659 }
660
661 #else
662 static int dummy;
663 #endif