OpenSSL:促使不安全的BIO保护它

问题描述 投票:1回答:1

我正在尝试使用OpenSSL在C ++中创建一个简单的FTP / FTPS客户端实现。我已经设法使用BIO API使用普通FTP。现在的问题是:一旦我有一个不安全的连接和BIO对象,我怎样才能升级连接以使用加密?连接在普通FTP中工作,直到发送AUTH TLS命令,此时应协商TLS / SSL会话。有BIO_new_ssl_connect函数,但是AFAIK,它不是重用现有连接,而是创建一个新连接。

我正在学习本教程:https://www.ibm.com/developerworks/linux/library/l-openssl/index.html

c++ ssl ftp openssl ftps
1个回答
0
投票

检查BIO_new_ssl_connect source code

BIO *BIO_new_ssl_connect(SSL_CTX *ctx)
{
#ifndef OPENSSL_NO_SOCK
    BIO *ret = NULL, *con = NULL, *ssl = NULL;

    if ((con = BIO_new(BIO_s_connect())) == NULL)
        return (NULL);
    if ((ssl = BIO_new_ssl(ctx, 1)) == NULL)
        goto err;
    if ((ret = BIO_push(ssl, con)) == NULL)
        goto err;
    return (ret);
 err:
    BIO_free(con);
#endif
    return (NULL);
}

同样,跳过BIO_s_connect

© www.soinside.com 2019 - 2024. All rights reserved.