Openssl 프로그래밍 중인데 도와주세요
13982:error:140A90A1:SSL routines:SSL_CTX_new:library has no ciphers:ssl_lib.c:1424:
실행 시키면 이런 에러가 뜹니다.
암호화 셋이 없다는거 같은데 ㅠㅠ
이거 어떻게 수정해야 하나요?
코드는
#include
#include
#include "openssl/bio.h"
#include "openssl/ssl.h"
#include "openssl/err.h"
int password_callback(char *buf, int size, int rwflag, void *userdata)
{
/*비밀번호는 1234*/
printf("패스워드를 콜백\n");
strcpy(buf, "1234"); //암호 복사
return 1;
}
int main()
{
SSL *ssl;
BIO *bio, *bio1, *out;
SSL_load_error_strings();
ERR_load_BIO_strings();
ERR_load_SSL_strings();
SSLeay_add_all_algorithms();
SSL_METHOD *meth;
meth = SSLv23_server_method();
SSL_CTX* ctx;
ctx= SSL_CTX_new(meth);
SSL_library_init();
int (*callback)(char *, int, int, void *) = &password_callback;
printf("SSL 시작\n");
if(!ctx)
{
ERR_print_errors_fp(stderr);
printf("실패\n");
return 0;
}
printf("SSL 콘텍스트 설치\n");
SSL_CTX_set_default_passwd_cb(ctx, callback);
if(!SSL_CTX_use_certificate_file(ctx, "certificate.pem", SSL_FILETYPE_PEM))
{
ERR_print_errors_fp(stdout);
SSL_CTX_free(ctx);
return 0;
}
if(SSL_CTX_use_PrivateKey_file(ctx, "private.key", SSL_FILETYPE_PEM)<1)
{
ERR_print_errors_fp(stderr);
return 0;
}
if(!SSL_CTX_check_private_key(ctx)){
fprintf(stderr, "개인키가 틀렸습니다\n");
return 0;
}
printf("\nAttempting to set up BIO for SSL...\n");
BIO_get_ssl(bio, &ssl);
SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);
bio1 = BIO_new_accept("4422");
BIO_set_accept_bios(bio1, bio);
printf("Waiting for incoming connection...\n");
if(BIO_do_accept(bio1) <= 0)
{
ERR_print_errors_fp(stdout);
SSL_CTX_free(ctx);
BIO_free_all(bio);
BIO_free_all(bio1);
return;
}
if(BIO_do_accept(bio1) <= 0)
{
ERR_print_errors_fp(stdout);
SSL_CTX_free(ctx);
BIO_free_all(bio);
BIO_free_all(bio1);
return;
}
out = BIO_pop(bio1);
if(BIO_do_handshake(out) <= 0)
{
printf("Handshake failed.\n");
ERR_print_errors_fp(stdout);
SSL_CTX_free(ctx);
BIO_free_all(bio);
BIO_free_all(bio1);
return;
}
BIO_puts(out, "Hello\n");
BIO_flush(out);
BIO_free_all(out);
BIO_free_all(bio);
BIO_free_all(bio1);
SSL_CTX_free(ctx);
}
댓글 달기