Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9181689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:22:41+00:00 2026-06-17T18:22:41+00:00

I’m trying to learn how to use the OpenSSL library (total newb) and am

  • 0

I’m trying to learn how to use the OpenSSL library (total newb) and am having a bit of trouble figuring out how to have a client connect to a server with the correct cert, and fail if the cert is incorrect. My use case is build a p2p application with no central CA, so I cannot rely on a CA cert. Specifically, the server has a cert/key as usual, and the client will determine a server’s cert by asking other p2p nodes to vote.

I have two specific questions:

  • In the below code snippets, I expect the client to not connect if I
    comment out the selection below ‘cipher list’. It still works! I’m missing something, right?
  • Is there a way to just have the client use a server cert, and have that be sufficient for opening up a connection? Ie no key, no CA?

client:

ctx = SSL_CTX_new(DTLSv1_client_method());
SSL_CTX_set_cipher_list(ctx, "HIGH:!DSS:!aNULL@STRENGTH");

// If I comment out below stuff, client still connects happily!?
if (!SSL_CTX_use_certificate_file(ctx, "certs/server-cert.pem", SSL_FILETYPE_PEM))
    printf("\nERROR: no certificate found!");

if (!SSL_CTX_use_PrivateKey_file(ctx, "certs/server-key.pem", SSL_FILETYPE_PEM))
    printf("\nERROR: no private key found!");

if (!SSL_CTX_check_private_key (ctx))
    printf("\nERROR: invalid private key!");

server:

SSL_CTX_set_cipher_list(ctx, "HIGH:!DSS:!aNULL@STRENGTH"); // high strength ciphers
SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_OFF);

if (!SSL_CTX_use_certificate_file(ctx, "certs/server-cert.pem", SSL_FILETYPE_PEM))
    printf("\nERROR: no certificate found!");

if (!SSL_CTX_use_PrivateKey_file(ctx, "certs/server-key.pem", SSL_FILETYPE_PEM))
    printf("\nERROR: no private key found!");

if (!SSL_CTX_check_private_key (ctx))
    printf("\nERROR: invalid private key!");

My code is at https://github.com/a34729t/exp/tree/master/tun2udp/dtls; it’s built of Robin Seggelmann’s DTLS examples. Specifically, I’m working with server3_oo.c.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:22:43+00:00Added an answer on June 17, 2026 at 6:22 pm

    SSL/TLS can operate in different modes. The most common mode is server authentication only, in which only the server has a certificate and key. Then there is mutual authentication mode, also called client authentication, in which the client also has a (client) certificate and key. And then there is a fully anonymous mode where neither server nor client authenticate themselves, and neither needs a certificate and key.

    Unless you tell OpenSSL otherwise, it will operate in server authentication only mode. In this mode, these lines here in the client:

    if (!SSL_CTX_use_certificate_file(ctx, "certs/server-cert.pem", SSL_FILETYPE_PEM))
        printf("\nERROR: no certificate found!");
    if (!SSL_CTX_use_PrivateKey_file(ctx, "certs/server-key.pem", SSL_FILETYPE_PEM))
        printf("\nERROR: no private key found!");
    

    will cause the client to load a client certificate (btw, you do never have to load the server cert and key in the client). However, since the server does not ask the client for a certificate, the client never presents one. Commenting these lines out makes the client not load any client certs, which makes no difference since they aren’t being used anyway.

    To make the server ask the client for a certificate, and have the server refuse the connection if none is presented, you have to tell the server like this (error handling omitted):

    SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL);
    

    SSL_VERIFY_PEER makes the server ask for a client cert, and SSL_VERIFY_FAIL_IF_NO_PEER_CERT causes the server to abort the connection if the client presents no certificate (see documentation). If you don’t use the latter option, you can check for yourself if the client sent a certificate using the SSL_get_peer_certificate function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.