ssl sockets

This is a discussion on ssl sockets within the Linux Programming forums, part of the Platform Specific Boards category; I have written a server and client using the openSSL api for security. And my problem comes when i want ...

  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.

  2. #2
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    Posts
    533
    try the server side, make sure they both have the same formats. see if you can isolate the exact area of the code it is on. Look for examples on the web similar to your code

    http://www.google.com/search?q=SSL+S...mming+on+Linux
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

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, 02:43 PM
  2. rewrite function for ssl compatibility
    By keeper in forum C++ Programming
    Replies: 1
    Last Post: 06-02-2006, 01: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21