2 * Copyright (c) 2018 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #include <openssl/ssl.h>
17 #include <openssl/conf.h>
18 #include <openssl/err.h>
19 #ifdef HAVE_OPENSSL_ASYNC
20 #include <openssl/async.h>
23 #include <vnet/plugin/plugin.h>
24 #include <vpp/app/version.h>
25 #include <vnet/tls/tls.h>
27 #include <tlsopenssl/tls_openssl.h>
29 #define MAX_CRYPTO_LEN 16
31 static openssl_main_t openssl_main;
33 openssl_ctx_alloc (void)
35 u8 thread_index = vlib_get_thread_index ();
36 openssl_main_t *tm = &openssl_main;
39 pool_get (tm->ctx_pool[thread_index], ctx);
41 *ctx = clib_mem_alloc (sizeof (openssl_ctx_t));
43 memset (*ctx, 0, sizeof (openssl_ctx_t));
44 (*ctx)->ctx.c_thread_index = thread_index;
45 (*ctx)->ctx.tls_ctx_engine = TLS_ENGINE_OPENSSL;
46 (*ctx)->ctx.app_session_handle = SESSION_INVALID_HANDLE;
47 (*ctx)->openssl_ctx_index = ctx - tm->ctx_pool[thread_index];
48 return ((*ctx)->openssl_ctx_index);
52 openssl_ctx_free (tls_ctx_t * ctx)
54 openssl_ctx_t *oc = (openssl_ctx_t *) ctx;
56 if (SSL_is_init_finished (oc->ssl) && !ctx->is_passive_close)
57 SSL_shutdown (oc->ssl);
61 pool_put_index (openssl_main.ctx_pool[ctx->c_thread_index],
62 oc->openssl_ctx_index);
66 openssl_ctx_get (u32 ctx_index)
69 ctx = pool_elt_at_index (openssl_main.ctx_pool[vlib_get_thread_index ()],
75 openssl_ctx_get_w_thread (u32 ctx_index, u8 thread_index)
78 ctx = pool_elt_at_index (openssl_main.ctx_pool[thread_index], ctx_index);
83 openssl_listen_ctx_alloc (void)
85 openssl_main_t *om = &openssl_main;
86 openssl_listen_ctx_t *lctx;
88 pool_get (om->lctx_pool, lctx);
90 memset (lctx, 0, sizeof (openssl_listen_ctx_t));
91 lctx->openssl_lctx_index = lctx - om->lctx_pool;
92 return lctx->openssl_lctx_index;
96 openssl_listen_ctx_free (openssl_listen_ctx_t * lctx)
98 pool_put_index (openssl_main.lctx_pool, lctx->openssl_lctx_index);
101 openssl_listen_ctx_t *
102 openssl_lctx_get (u32 lctx_index)
104 return pool_elt_at_index (openssl_main.lctx_pool, lctx_index);
108 openssl_try_handshake_read (openssl_ctx_t * oc,
109 stream_session_t * tls_session)
111 u32 deq_max, deq_now;
115 f = tls_session->server_rx_fifo;
116 deq_max = svm_fifo_max_dequeue (f);
120 deq_now = clib_min (svm_fifo_max_read_chunk (f), deq_max);
121 wrote = BIO_write (oc->wbio, svm_fifo_head (f), deq_now);
125 svm_fifo_dequeue_drop (f, wrote);
128 deq_now = clib_min (svm_fifo_max_read_chunk (f), deq_max - wrote);
129 rv = BIO_write (oc->wbio, svm_fifo_head (f), deq_now);
132 svm_fifo_dequeue_drop (f, rv);
140 openssl_try_handshake_write (openssl_ctx_t * oc,
141 stream_session_t * tls_session)
143 u32 enq_max, deq_now;
147 if (BIO_ctrl_pending (oc->rbio) <= 0)
150 f = tls_session->server_tx_fifo;
151 enq_max = svm_fifo_max_enqueue (f);
155 deq_now = clib_min (svm_fifo_max_write_chunk (f), enq_max);
156 read = BIO_read (oc->rbio, svm_fifo_tail (f), deq_now);
160 svm_fifo_enqueue_nocopy (f, read);
161 tls_add_vpp_q_evt (f, FIFO_EVENT_APP_TX);
165 deq_now = clib_min (svm_fifo_max_write_chunk (f), enq_max - read);
166 rv = BIO_read (oc->rbio, svm_fifo_tail (f), deq_now);
169 svm_fifo_enqueue_nocopy (f, rv);
177 #ifdef HAVE_OPENSSL_ASYNC
179 vpp_ssl_async_process_event (tls_ctx_t * ctx,
180 openssl_resume_handler * handler)
182 openssl_ctx_t *oc = (openssl_ctx_t *) ctx;
183 openssl_tls_callback_t *engine_cb;
185 engine_cb = vpp_add_async_pending_event (ctx, handler);
188 SSL_set_async_callback (oc->ssl, (void *) engine_cb->callback,
189 (void *) engine_cb->arg);
190 TLS_DBG (2, "set callback to engine %p\n", engine_cb->callback);
196 /* Due to engine busy stat, VPP need to retry later */
198 vpp_ssl_async_retry_func (tls_ctx_t * ctx, openssl_resume_handler * handler)
200 openssl_ctx_t *oc = (openssl_ctx_t *) ctx;
202 if (vpp_add_async_run_event (ctx, handler))
204 SSL_set_async_estatus (oc->ssl, 0);
213 openssl_ctx_handshake_rx (tls_ctx_t * ctx, stream_session_t * tls_session)
215 openssl_ctx_t *oc = (openssl_ctx_t *) ctx;
217 #ifdef HAVE_OPENSSL_ASYNC
219 openssl_resume_handler *myself;
222 while (SSL_in_init (oc->ssl))
228 else if (!openssl_try_handshake_read (oc, tls_session))
233 rv = SSL_do_handshake (oc->ssl);
234 err = SSL_get_error (oc->ssl, rv);
235 openssl_try_handshake_write (oc, tls_session);
236 #ifdef HAVE_OPENSSL_ASYNC
237 myself = openssl_ctx_handshake_rx;
238 if (SSL_get_async_estatus (oc->ssl, &estatus)
239 && (estatus == ENGINE_STATUS_RETRY))
241 vpp_ssl_async_retry_func (ctx, myself);
243 else if (err == SSL_ERROR_WANT_ASYNC)
245 vpp_ssl_async_process_event (ctx, myself);
249 if (err != SSL_ERROR_WANT_WRITE)
251 if (err == SSL_ERROR_SSL)
254 ERR_error_string (ERR_get_error (), buf);
255 clib_warning ("Err: %s", buf);
260 TLS_DBG (2, "tls state for %u is %s", oc->openssl_ctx_index,
261 SSL_state_string_long (oc->ssl));
263 if (SSL_in_init (oc->ssl))
269 if (!SSL_is_server (oc->ssl))
272 * Verify server certificate
274 if ((rv = SSL_get_verify_result (oc->ssl)) != X509_V_OK)
276 TLS_DBG (1, " failed verify: %s\n",
277 X509_verify_cert_error_string (rv));
280 * Presence of hostname enforces strict certificate verification
282 if (ctx->srv_hostname)
284 tls_notify_app_connected (ctx, /* is failed */ 0);
288 tls_notify_app_connected (ctx, /* is failed */ 0);
292 tls_notify_app_accept (ctx);
295 TLS_DBG (1, "Handshake for %u complete. TLS cipher is %s",
296 oc->openssl_ctx_index, SSL_get_cipher (oc->ssl));
301 openssl_ctx_write (tls_ctx_t * ctx, stream_session_t * app_session)
303 openssl_ctx_t *oc = (openssl_ctx_t *) ctx;
304 int wrote = 0, rv, read, max_buf = 100 * TLS_CHUNK_SIZE, max_space;
305 u32 enq_max, deq_max, deq_now, to_write;
306 stream_session_t *tls_session;
309 f = app_session->server_tx_fifo;
310 deq_max = svm_fifo_max_dequeue (f);
314 max_space = max_buf - BIO_ctrl_pending (oc->rbio);
315 max_space = (max_space < 0) ? 0 : max_space;
316 deq_now = clib_min (deq_max, (u32) max_space);
317 to_write = clib_min (svm_fifo_max_read_chunk (f), deq_now);
318 wrote = SSL_write (oc->ssl, svm_fifo_head (f), to_write);
321 tls_add_vpp_q_evt (app_session->server_tx_fifo, FIFO_EVENT_APP_TX);
324 svm_fifo_dequeue_drop (app_session->server_tx_fifo, wrote);
327 to_write = clib_min (svm_fifo_max_read_chunk (f), deq_now - wrote);
328 rv = SSL_write (oc->ssl, svm_fifo_head (f), to_write);
331 svm_fifo_dequeue_drop (app_session->server_tx_fifo, rv);
337 tls_add_vpp_q_evt (app_session->server_tx_fifo, FIFO_EVENT_APP_TX);
341 if (BIO_ctrl_pending (oc->rbio) <= 0)
344 tls_session = session_get_from_handle (ctx->tls_session_handle);
345 f = tls_session->server_tx_fifo;
346 enq_max = svm_fifo_max_enqueue (f);
349 tls_add_vpp_q_evt (app_session->server_tx_fifo, FIFO_EVENT_APP_TX);
353 deq_now = clib_min (svm_fifo_max_write_chunk (f), enq_max);
354 read = BIO_read (oc->rbio, svm_fifo_tail (f), deq_now);
357 tls_add_vpp_q_evt (app_session->server_tx_fifo, FIFO_EVENT_APP_TX);
361 svm_fifo_enqueue_nocopy (f, read);
362 tls_add_vpp_q_evt (f, FIFO_EVENT_APP_TX);
364 if (read < enq_max && BIO_ctrl_pending (oc->rbio) > 0)
366 deq_now = clib_min (svm_fifo_max_write_chunk (f), enq_max - read);
367 read = BIO_read (oc->rbio, svm_fifo_tail (f), deq_now);
369 svm_fifo_enqueue_nocopy (f, read);
372 if (BIO_ctrl_pending (oc->rbio) > 0)
373 tls_add_vpp_q_evt (app_session->server_tx_fifo, FIFO_EVENT_APP_TX);
379 openssl_ctx_read (tls_ctx_t * ctx, stream_session_t * tls_session)
381 int read, wrote = 0, max_space, max_buf = 100 * TLS_CHUNK_SIZE, rv;
382 openssl_ctx_t *oc = (openssl_ctx_t *) ctx;
383 u32 deq_max, enq_max, deq_now, to_read;
384 stream_session_t *app_session;
387 if (PREDICT_FALSE (SSL_in_init (oc->ssl)))
389 openssl_ctx_handshake_rx (ctx, tls_session);
393 f = tls_session->server_rx_fifo;
394 deq_max = svm_fifo_max_dequeue (f);
395 max_space = max_buf - BIO_ctrl_pending (oc->wbio);
396 max_space = max_space < 0 ? 0 : max_space;
397 deq_now = clib_min (deq_max, max_space);
401 to_read = clib_min (svm_fifo_max_read_chunk (f), deq_now);
402 wrote = BIO_write (oc->wbio, svm_fifo_head (f), to_read);
405 tls_add_vpp_q_evt (tls_session->server_rx_fifo, FIFO_EVENT_BUILTIN_RX);
408 svm_fifo_dequeue_drop (f, wrote);
411 to_read = clib_min (svm_fifo_max_read_chunk (f), deq_now - wrote);
412 rv = BIO_write (oc->wbio, svm_fifo_head (f), to_read);
415 svm_fifo_dequeue_drop (f, rv);
419 if (svm_fifo_max_dequeue (f))
420 tls_add_vpp_q_evt (tls_session->server_rx_fifo, FIFO_EVENT_BUILTIN_RX);
424 if (BIO_ctrl_pending (oc->wbio) <= 0)
427 app_session = session_get_from_handle (ctx->app_session_handle);
428 f = app_session->server_rx_fifo;
429 enq_max = svm_fifo_max_enqueue (f);
432 tls_add_vpp_q_evt (tls_session->server_rx_fifo, FIFO_EVENT_BUILTIN_RX);
436 deq_now = clib_min (svm_fifo_max_write_chunk (f), enq_max);
437 read = SSL_read (oc->ssl, svm_fifo_tail (f), deq_now);
440 tls_add_vpp_q_evt (tls_session->server_rx_fifo, FIFO_EVENT_BUILTIN_RX);
443 svm_fifo_enqueue_nocopy (f, read);
444 if (read < enq_max && BIO_ctrl_pending (oc->wbio) > 0)
446 deq_now = clib_min (svm_fifo_max_write_chunk (f), enq_max - read);
447 read = SSL_read (oc->ssl, svm_fifo_tail (f), deq_now);
449 svm_fifo_enqueue_nocopy (f, read);
452 tls_notify_app_enqueue (ctx, app_session);
453 if (BIO_ctrl_pending (oc->wbio) > 0)
454 tls_add_vpp_q_evt (tls_session->server_rx_fifo, FIFO_EVENT_BUILTIN_RX);
460 openssl_ctx_init_client (tls_ctx_t * ctx)
462 long flags = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_COMPRESSION;
463 openssl_ctx_t *oc = (openssl_ctx_t *) ctx;
464 openssl_main_t *om = &openssl_main;
465 stream_session_t *tls_session;
466 const SSL_METHOD *method;
468 #ifdef HAVE_OPENSSL_ASYNC
469 openssl_resume_handler *handler;
472 method = SSLv23_client_method ();
475 TLS_DBG (1, "SSLv23_method returned null");
479 oc->ssl_ctx = SSL_CTX_new (method);
480 if (oc->ssl_ctx == NULL)
482 TLS_DBG (1, "SSL_CTX_new returned null");
486 SSL_CTX_set_ecdh_auto (oc->ssl_ctx, 1);
487 SSL_CTX_set_mode (oc->ssl_ctx, SSL_MODE_ENABLE_PARTIAL_WRITE);
488 #ifdef HAVE_OPENSSL_ASYNC
490 SSL_CTX_set_mode (oc->ssl_ctx, SSL_MODE_ASYNC);
492 rv = SSL_CTX_set_cipher_list (oc->ssl_ctx, (const char *) om->ciphers);
495 TLS_DBG (1, "Couldn't set cipher");
499 SSL_CTX_set_options (oc->ssl_ctx, flags);
500 SSL_CTX_set_cert_store (oc->ssl_ctx, om->cert_store);
502 oc->ssl = SSL_new (oc->ssl_ctx);
505 TLS_DBG (1, "Couldn't initialize ssl struct");
509 oc->rbio = BIO_new (BIO_s_mem ());
510 oc->wbio = BIO_new (BIO_s_mem ());
512 BIO_set_mem_eof_return (oc->rbio, -1);
513 BIO_set_mem_eof_return (oc->wbio, -1);
515 SSL_set_bio (oc->ssl, oc->wbio, oc->rbio);
516 SSL_set_connect_state (oc->ssl);
518 rv = SSL_set_tlsext_host_name (oc->ssl, ctx->srv_hostname);
521 TLS_DBG (1, "Couldn't set hostname");
526 * 2. Do the first steps in the handshake.
528 TLS_DBG (1, "Initiating handshake for [%u]%u", ctx->c_thread_index,
529 oc->openssl_ctx_index);
531 tls_session = session_get_from_handle (ctx->tls_session_handle);
534 rv = SSL_do_handshake (oc->ssl);
535 err = SSL_get_error (oc->ssl, rv);
536 openssl_try_handshake_write (oc, tls_session);
537 #ifdef HAVE_OPENSSL_ASYNC
538 if (err == SSL_ERROR_WANT_ASYNC)
540 handler = (openssl_resume_handler *) openssl_ctx_handshake_rx;
541 vpp_ssl_async_process_event (ctx, handler);
545 if (err != SSL_ERROR_WANT_WRITE)
549 TLS_DBG (2, "tls state for [%u]%u is su", ctx->c_thread_index,
550 oc->openssl_ctx_index, SSL_state_string_long (oc->ssl));
555 openssl_start_listen (tls_ctx_t * lctx)
558 const SSL_METHOD *method;
565 openssl_listen_ctx_t *olc;
567 long flags = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_COMPRESSION;
568 openssl_main_t *om = &openssl_main;
570 app = application_get (lctx->parent_app_index);
571 if (!app->tls_cert || !app->tls_key)
573 TLS_DBG (1, "tls cert and/or key not configured %d",
574 lctx->parent_app_index);
578 method = SSLv23_method ();
579 ssl_ctx = SSL_CTX_new (method);
582 clib_warning ("Unable to create SSL context");
586 SSL_CTX_set_mode (ssl_ctx, SSL_MODE_ENABLE_PARTIAL_WRITE);
587 #ifdef HAVE_OPENSSL_ASYNC
589 SSL_CTX_set_mode (ssl_ctx, SSL_MODE_ASYNC);
591 SSL_CTX_set_options (ssl_ctx, flags);
592 SSL_CTX_set_ecdh_auto (ssl_ctx, 1);
594 rv = SSL_CTX_set_cipher_list (ssl_ctx, (const char *) om->ciphers);
597 TLS_DBG (1, "Couldn't set cipher");
602 * Set the key and cert
604 cert_bio = BIO_new (BIO_s_mem ());
605 BIO_write (cert_bio, app->tls_cert, vec_len (app->tls_cert));
606 srvcert = PEM_read_bio_X509 (cert_bio, NULL, NULL, NULL);
609 clib_warning ("unable to parse certificate");
612 SSL_CTX_use_certificate (ssl_ctx, srvcert);
615 cert_bio = BIO_new (BIO_s_mem ());
616 BIO_write (cert_bio, app->tls_key, vec_len (app->tls_key));
617 pkey = PEM_read_bio_PrivateKey (cert_bio, NULL, NULL, NULL);
620 clib_warning ("unable to parse pkey");
623 SSL_CTX_use_PrivateKey (ssl_ctx, pkey);
626 olc_index = openssl_listen_ctx_alloc ();
627 olc = openssl_lctx_get (olc_index);
628 olc->ssl_ctx = ssl_ctx;
629 olc->srvcert = srvcert;
632 /* store SSL_CTX into TLS level structure */
633 lctx->tls_ssl_ctx = olc_index;
640 openssl_stop_listen (tls_ctx_t * lctx)
643 openssl_listen_ctx_t *olc;
645 olc_index = lctx->tls_ssl_ctx;
646 olc = openssl_lctx_get (olc_index);
648 X509_free (olc->srvcert);
649 EVP_PKEY_free (olc->pkey);
651 SSL_CTX_free (olc->ssl_ctx);
652 openssl_listen_ctx_free (olc);
658 openssl_ctx_init_server (tls_ctx_t * ctx)
660 openssl_ctx_t *oc = (openssl_ctx_t *) ctx;
661 u32 olc_index = ctx->tls_ssl_ctx;
662 openssl_listen_ctx_t *olc;
663 stream_session_t *tls_session;
665 #ifdef HAVE_OPENSSL_ASYNC
666 openssl_resume_handler *handler;
669 /* Start a new connection */
671 olc = openssl_lctx_get (olc_index);
672 oc->ssl = SSL_new (olc->ssl_ctx);
675 TLS_DBG (1, "Couldn't initialize ssl struct");
679 oc->rbio = BIO_new (BIO_s_mem ());
680 oc->wbio = BIO_new (BIO_s_mem ());
682 BIO_set_mem_eof_return (oc->rbio, -1);
683 BIO_set_mem_eof_return (oc->wbio, -1);
685 SSL_set_bio (oc->ssl, oc->wbio, oc->rbio);
686 SSL_set_accept_state (oc->ssl);
688 TLS_DBG (1, "Initiating handshake for [%u]%u", ctx->c_thread_index,
689 oc->openssl_ctx_index);
691 tls_session = session_get_from_handle (ctx->tls_session_handle);
694 rv = SSL_do_handshake (oc->ssl);
695 err = SSL_get_error (oc->ssl, rv);
696 openssl_try_handshake_write (oc, tls_session);
697 #ifdef HAVE_OPENSSL_ASYNC
698 if (err == SSL_ERROR_WANT_ASYNC)
700 handler = (openssl_resume_handler *) openssl_ctx_handshake_rx;
701 vpp_ssl_async_process_event (ctx, handler);
705 if (err != SSL_ERROR_WANT_WRITE)
709 TLS_DBG (2, "tls state for [%u]%u is su", ctx->c_thread_index,
710 oc->openssl_ctx_index, SSL_state_string_long (oc->ssl));
715 openssl_handshake_is_over (tls_ctx_t * ctx)
717 openssl_ctx_t *mc = (openssl_ctx_t *) ctx;
720 return SSL_is_init_finished (mc->ssl);
723 const static tls_engine_vft_t openssl_engine = {
724 .ctx_alloc = openssl_ctx_alloc,
725 .ctx_free = openssl_ctx_free,
726 .ctx_get = openssl_ctx_get,
727 .ctx_get_w_thread = openssl_ctx_get_w_thread,
728 .ctx_init_server = openssl_ctx_init_server,
729 .ctx_init_client = openssl_ctx_init_client,
730 .ctx_write = openssl_ctx_write,
731 .ctx_read = openssl_ctx_read,
732 .ctx_handshake_is_over = openssl_handshake_is_over,
733 .ctx_start_listen = openssl_start_listen,
734 .ctx_stop_listen = openssl_stop_listen,
738 tls_init_ca_chain (void)
740 openssl_main_t *om = &openssl_main;
741 tls_main_t *tm = vnet_tls_get_main ();
746 if (access (tm->ca_cert_path, F_OK | R_OK) == -1)
748 clib_warning ("Could not initialize TLS CA certificates");
752 if (!(om->cert_store = X509_STORE_new ()))
754 clib_warning ("failed to create cert store");
758 rv = X509_STORE_load_locations (om->cert_store, tm->ca_cert_path, 0);
761 clib_warning ("failed to load ca certificate");
764 if (tm->use_test_cert_in_ca)
766 cert_bio = BIO_new (BIO_s_mem ());
767 BIO_write (cert_bio, test_srv_crt_rsa, test_srv_crt_rsa_len);
768 testcert = PEM_read_bio_X509 (cert_bio, NULL, NULL, NULL);
771 clib_warning ("unable to parse certificate");
774 X509_STORE_add_cert (om->cert_store, testcert);
777 return (rv < 0 ? -1 : 0);
781 tls_openssl_set_ciphers (char *ciphers)
783 openssl_main_t *om = &openssl_main;
791 vec_validate (om->ciphers, strlen (ciphers) - 1);
792 for (i = 0; i < vec_len (om->ciphers); i++)
794 om->ciphers[i] = toupper (ciphers[i]);
801 static clib_error_t *
802 tls_openssl_init (vlib_main_t * vm)
804 vlib_thread_main_t *vtm = vlib_get_thread_main ();
805 openssl_main_t *om = &openssl_main;
809 num_threads = 1 /* main thread */ + vtm->n_threads;
811 if ((error = vlib_call_init_function (vm, tls_init)))
815 SSL_load_error_strings ();
817 if (tls_init_ca_chain ())
819 clib_warning ("failed to initialize TLS CA chain");
823 vec_validate (om->ctx_pool, num_threads - 1);
825 tls_register_engine (&openssl_engine, TLS_ENGINE_OPENSSL);
829 /* default ciphers */
830 tls_openssl_set_ciphers
831 ("ALL:!ADH:!LOW:!EXP:!MD5:!RC4-SHA:!DES-CBC3-SHA:@STRENGTH");
836 #ifdef HAVE_OPENSSL_ASYNC
837 static clib_error_t *
838 tls_openssl_set_command_fn (vlib_main_t * vm, unformat_input_t * input,
839 vlib_cli_command_t * cmd)
841 openssl_main_t *om = &openssl_main;
842 char *engine_name = NULL;
843 char *engine_alg = NULL;
844 char *ciphers = NULL;
845 u8 engine_name_set = 0;
848 /* By present, it is not allowed to configure engine again after running */
851 clib_warning ("engine has started!\n");
852 return clib_error_return
853 (0, "engine has started, and no config is accepted");
856 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
858 if (unformat (input, "engine %s", &engine_name))
862 else if (unformat (input, "async"))
865 openssl_async_node_enable_disable (1);
867 else if (unformat (input, "alg %s", &engine_alg))
869 for (i = 0; i < strnlen (engine_alg, MAX_CRYPTO_LEN); i++)
870 engine_alg[i] = toupper (engine_alg[i]);
872 else if (unformat (input, "ciphers %s", &ciphers))
874 tls_openssl_set_ciphers (ciphers);
877 return clib_error_return (0, "failed: unknown input `%U'",
878 format_unformat_error, input);
881 /* reset parameters if engine is not configured */
882 if (!engine_name_set)
884 clib_warning ("No engine provided! \n");
889 if (!openssl_engine_register (engine_name, engine_alg))
891 return clib_error_return (0, "failed to register %s polling",
900 VLIB_CLI_COMMAND (tls_openssl_set_command, static) =
902 .path = "tls openssl set",
903 .short_help = "tls openssl set [engine <engine name>] [alg [algorithm] [async]",
904 .function = tls_openssl_set_command_fn,
910 VLIB_INIT_FUNCTION (tls_openssl_init);
913 VLIB_PLUGIN_REGISTER () = {
914 .version = VPP_BUILD_VER,
915 .description = "openssl based TLS Engine",
920 * fd.io coding-style-patch-verification: ON
923 * eval: (c-set-style "gnu")