小编Dav*_*ana的帖子

使用ssl c/c ++进行客户端和服务器通信 - SSL协议不起作用

我试图使用来自SSL客户端/服务器的例子:http://simplestcodings.blogspot.com.br/2010/08/secure-server-client-using-openssl-in-c.html使用创造一个安全连接SSLv3的.我在服务器端请求证书做了一些更改,通信工作正常并且双方都理解.因此,我的问题是,当客户端连接到服务器时,协议通信SSLv3无法正常工作,我使用wirkeshark进行验证,并且在协议字段中只显示TCP或IPA(RSL格式错误的数据包)有人可以帮助我吗?谢谢!

我按照教程https://help.ubuntu.com/community/OpenSSL创建了我的证书.

这是我的客户端代码:

//SSL-Client.c
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <malloc.h>
#include <string.h>
#include <sys/socket.h>
#include <resolv.h>
#include <netdb.h>
#include <openssl/ssl.h>
#include <openssl/err.h>

#define FAIL    -1

    //Added the LoadCertificates how in the server-side makes.    
void LoadCertificates(SSL_CTX* ctx, char* CertFile, char* KeyFile)
{
 /* set the local certificate from CertFile */
    if ( SSL_CTX_use_certificate_file(ctx, CertFile, SSL_FILETYPE_PEM) <= 0 )
    {
        ERR_print_errors_fp(stderr);
        abort();
    }
    /* set the private key from KeyFile (may be the same as CertFile) …
Run Code Online (Sandbox Code Playgroud)

c c++ sockets openssl ssl-certificate

19
推荐指数
2
解决办法
8万
查看次数

如何从unsigned char*modulus和exponent 65537(RSA_F4)创建RSA公钥

我正在尝试从模数类型char []生成一个rsa公钥,现在我的指数是RSA_F4(65537); 但是,当我尝试使用"n"和"e"的值生成我的公钥时,RSA_public_encrypt,返回-1;

谢谢!

我的代码:

#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <crypt.h>
#include <iostream>
#include <stdlib.h>
#include <openssl/rsa.h>
#include <openssl/aes.h>
#include <openssl/opensslconf.h>
#include <openssl/engine.h>
#include <openssl/pem.h>
#include <openssl/rc4.h>

using namespace std;
int main(void)
{

//modulus in format char hex;
char key[] = "C0E7FC730EB5CF85B040EC25DAEF288912641889AD651B3707CFED9FC5A1D3F6C40062AD46E3B3C3E21D4E71CC4800C80226D453242AEB2F86D748B41DDF35FD";

    char palavra[] = "teste";
    char crip[512];
    int ret;
    RSA * pubkey = RSA_new();
    BIGNUM * modul = BN_new();
    BIGNUM * expon = BN_new();

    BN_hex2bn(&modul, (const char *) key);
    BN_hex2bn(&expon, "010001");

    cout << "N KEY: " << …
Run Code Online (Sandbox Code Playgroud)

c c++ linux openssl

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

c ×2

c++ ×2

openssl ×2

linux ×1

sockets ×1

ssl-certificate ×1