开始使用OpenSSL [英] Starting to use OpenSSL

查看:112
本文介绍了开始使用OpenSSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的跨平台程序中使用SSL.我决定使用OpenSSL.

I want to use SSL in my cross platform program. I decided to use OpenSSL.

我已经安装了OpenSSL,这时我正在浏览代码和文档,试图弄清楚如何使用该库.

I have OpenSSL installed, and at this point I am looking through the code and documentation trying to figure out how to use the library.

您是否有任何资源,简单的程序或教程可以帮助我逐步将OpenSSL与我的程序集成在一起?

Do you have any resources or simple programs or tutorials that will walk me through integrating OpenSSL with my program?

推荐答案

非常粗略的指南是:

  • Create a new SSL_CTX with SSL_CTX_new();
  • (server only) Load the certificate with SSL_CTX_use_certificate_file();
  • (server only) Load the private key with SSL_CTX_use_PrivateKey_file();
  • Establish the network connection;
  • Create a new SSL with SSL_new();
  • Set the file descriptor of the SSL to that of your network connection with SSL_set_fd();
  • (client only) Call SSL_connect();
  • (server only) Call SSL_accept().

此后使用 SSL_read()

Thereafter use SSL_read() and SSL_write() to read and write from the connection, and finish with SSL_shutdown(). The SSL_CTX can be re-used to create SSL objects for many simultaneous sessions.

这篇关于开始使用OpenSSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆