openssl 관련 소스 실행이 안됩니다. 도움 꼭 부탁드립니다.

hopeful1213의 이미지

여기저기 도움을 얻어서 아래와 같은 openssl 소스까지 갔습니다.
그런데 계속 런타임 에러만 나네요. (리눅스 소스를 윈도우로 바꿔
서 실행중입니다. 마땅히 질문드릴때가 없어서.. 죄송합니다.)

디버깅 해본 결과는.
// meth = SSLv3_method();
meth = TLSv1_method();

이부분에서 계속 meth 값이 NULL이 나옵니다.
meth = SSLv23_client_method(); 등 여러가지를 써보았는데
도 계속 실행이 안되네여..
컴파일, 링크까지는 진행되었지만 런타임때 에러가 나서 정말 답답합니다.

고수님들 꼭 도움 부탁드립니다.

 

#include <openssl/rsa.h>       /* SSLeay stuff */ 
#include <openssl/crypto.h> 
#include <openssl/x509.h> 
#include <openssl/pem.h> 
#include <openssl/ssl.h> 
#include <openssl/err.h> 
#include <openssl/rand.h> 
#include <stdio.h>
#include <string.h>

//  OpenSSL library를 사용하기 위해 필요한 초기화 작업을 한다.
#define SETUP_OPENSSL {                                                             \
            OpenSSL_add_all_algorithms();                                           \
            OpenSSL_add_all_ciphers();                                              \
            ERR_load_crypto_strings();                                              \
            static const char rnd_seed[] = "string to make the random number generator think it has entropy";   \
            RAND_seed(rnd_seed, sizeof(rnd_seed));                                  \
     }


int main()
{
	SETUP_OPENSSL;
    BIO * bio;
    SSL * ssl;
    SSL_CTX * ctx;
SSL_METHOD *meth; 

   int p;

    char * request = "GET / HTTP/1.1\x0D\x0AHost: www.verisign.com\x0D\x0A\x43onnection: Close\x0D\x0A\x0D\x0A";
    char r[1024];
	char *pathcert = "c:\\OpenSSL\\bin\\cert";
  
	/* Set up the library */
 // meth = SSLv3_method(); 
  meth = TLSv1_method(); 


   // create a new SSL_CTX object as framework for TLS/SSL enabled functions 
    ctx = SSL_CTX_new (meth); 
    if (!ctx) { 
		printf("error!!!!\n");
        ERR_print_errors_fp(stderr); 
        exit(2); 
    } 

 /* Load the trust store */
    if(!SSL_CTX_load_verify_locations(ctx, "c:\\OpenSSL\\bin\\PEM\\ca-cert.pem",NULL))
    {
		printf("error!!!\n");
        //fprintf(stderr, "Error loading trust store\n");
        //ERR_print_errors_fp(stderr);
        //SSL_CTX_free(ctx);
        return 0;
    }

spacelee의 이미지

저도 잘은 모르지만 SSL_library_init 도 부르셔야 되지않나여?
이 함수랑 SSL_load_error_strings 이것도..
그리고 초기화 함수들 에러 체크도 해봐야 할거 같은데여..

권위를 의심할 것,어긋남을 존경할 것,자리잡기를 거부할 것,항상 자신을 재창조할 것 - MIT 미디어랩 -

hopeful1213의 이미지

spacelee 님 조언 처럼
SSL_library_init ,SSL_load_error_strings 를 해보았는데도 마찬가지네요.

혹시 프로그램 설정하는 쪽에서 뭔가 있는 건 아닌지요?

spacelee의 이미지

hopeful1213 wrote:
spacelee 님 조언 처럼
SSL_library_init ,SSL_load_error_strings 를 해보았는데도 마찬가지네요.

혹시 프로그램 설정하는 쪽에서 뭔가 있는 건 아닌지요?

ssl 라이브러리에 링크하는 것 말고는 없었던것 같은데..

www.openssl.org에서 가끔 최신 버젼 라이브러리가
에러가 나서 몇몇 이전 버젼을 받아서 설치하고
해보니 됐던 적은 있습니다.

아니면 ssl 라이브러리 콜하는 순서나 에러처리나
그런 문제 인거 같기도 한데..

오라일리 openssl 책을 권장해드리고 싶네요..

권위를 의심할 것,어긋남을 존경할 것,자리잡기를 거부할 것,항상 자신을 재창조할 것 - MIT 미디어랩 -

oasis의 이미지

google신에게 질문하세요. 예제 많이 나옵니다.

익명 사용자의 이미지

OpenSSL_add_all_algorithms()를 SSLeay_add_ssl_algorithm()로 바꿔보세요.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.