Thread: ssl sockets

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    3

    ssl sockets

    I have written a server and client using the openSSL api
    for security. And my problem comes when i want to verify the certificate
    at the client side.

    Code:
        if(SSL_get_verify_result(ssl)!=X509_V_OK)
          berr_exit("Certificate doesn't verify");
    This function verifies the the certificate, and the function returns
    with the error message showed.

    But I don't know why the certificate does'nt verify.

    On the server I use the certificate & private key that i created with
    the openssl command tool.

    the code for using the certifcate is:

    Code:
    // set the locale certificate from cerfile
    if (SSL_CTX_use_certificate_file(ctx, certfile, SSL_FILETYPE_PEM) <= 0)
    {
         fprintf(stderr, "error cert\n");
         ERR_print_errors_fp(stderr);
         abort();
    }
    
    // set the private key from keyfile
    if (SSL_CTX_use_PrivateKey_file(ctx, keyfile, SSL_FILETYPE_PEM) <= 0)
    {
          fprintf(stderr, "error key\n");
          ERR_print_errors_fp(stderr);
          abort();
    }
    
    // verify private key
    if (!SSL_CTX_check_private_key(ctx))
    {
        fprintf(stderr, "Private key does not math the public certificate\n");
        
       abort();
    }
    the certificate was created like this

    // private key
    openssl genrsa -des3 -out server.key 1024

    // csr
    openssl req -new -days 365 -key server.key -out server.csr

    // CA
    openssl genrsa -des3 -out ca.key 1024
    openssl req -new -x509 -days 365 -key ca.key -out ca.crt

    ./sign server.csr


    ------------------------------

    i dont know where the error can be.

    anyone have any ideas?
    Last edited by champ; 04-04-2003 at 06:36 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Best way to poll sockets?
    By 39ster in forum Networking/Device Communication
    Replies: 3
    Last Post: 07-22-2008, 01:43 PM
  2. rewrite function for ssl compatibility
    By keeper in forum C++ Programming
    Replies: 1
    Last Post: 06-02-2006, 12:31 PM
  3. multiple UDP sockets with select()
    By nkhambal in forum Networking/Device Communication
    Replies: 2
    Last Post: 01-17-2006, 07:36 PM
  4. SSL and 503 FTP Error :: Socket
    By kuphryn in forum Networking/Device Communication
    Replies: 2
    Last Post: 03-18-2005, 04:15 PM
  5. Starting window sockets
    By _Cl0wn_ in forum Windows Programming
    Replies: 2
    Last Post: 01-20-2003, 11:49 AM