| 647 | } |
| 648 | |
| 649 | bool TcpSocket::initSSL |
| 650 | ( |
| 651 | const char *certs |
| 652 | ) |
| 653 | { |
| 654 | SSLCtx *ctx = (SSLCtx*)_sslctx; |
| 655 | if(ctx) |
| 656 | ctx->reset(); |
| 657 | else |
| 658 | { |
| 659 | ctx = new SSLCtx(); |
| 660 | _sslctx = ctx; |
| 661 | if(!ctx->init()) |
| 662 | { |
| 663 | shutdownSSL(); |
| 664 | return false; |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | if(certs) |
| 669 | { |
| 670 | int err = x509_crt_parse(&ctx->cacert, (const unsigned char*)certs, strlen(certs)); |
| 671 | if(err) |
| 672 | { |
| 673 | shutdownSSL(); |
| 674 | traceprint("x509_crt_parse() returned %d\n", err); |
| 675 | return false; |
| 676 | } |
| 677 | } |
| 678 | |
| 679 | return true; |
| 680 | } |
| 681 | |
| 682 | SSLResult TcpSocket::verifySSL |
| 683 | ( |