Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

For every problem there is one solution which is simple, neat, and wrong. -- H. L. Mencken


devel / comp.lang.c++ / OpenSSL (old) tutorial-style example programs ?

SubjectAuthor
* OpenSSL (old) tutorial-style example programs ?R.Wieser
+* Re: OpenSSL (old) tutorial-style example programs ?Paavo Helde
|+- Re: OpenSSL (old) tutorial-style example programs ?Paavo Helde
|+* Re: OpenSSL (old) tutorial-style example programs ?Muttley
||+* Re: OpenSSL (old) tutorial-style example programs ?R.Wieser
|||`- Re: OpenSSL (old) tutorial-style example programs ?Muttley
||`- Re: OpenSSL (old) tutorial-style example programs ?Paavo Helde
|`* Re: OpenSSL (old) tutorial-style example programs ?R.Wieser
| +* Re: OpenSSL (old) tutorial-style example programs ?Scott Lurndal
| |`- Re: OpenSSL (old) tutorial-style example programs ?Keith Thompson
| `* Re: OpenSSL (old) tutorial-style example programs ?Paavo Helde
|  `* Re: OpenSSL (old) tutorial-style example programs ?R.Wieser
|   `* Re: OpenSSL (old) tutorial-style example programs ?Paavo Helde
|    `* Re: OpenSSL (old) tutorial-style example programs ?R.Wieser
|     `* Re: OpenSSL (old) tutorial-style example programs ?Paavo Helde
|      `* Re: OpenSSL (old) tutorial-style example programs ?R.Wieser
|       +* Re: OpenSSL (old) tutorial-style example programs ?Paavo Helde
|       |`* Re: OpenSSL (old) tutorial-style example programs ?R.Wieser
|       | +* Re: OpenSSL (old) tutorial-style example programs ?Scott Lurndal
|       | |`* Re: OpenSSL (old) tutorial-style example programs ?R.Wieser
|       | | `* Re: OpenSSL (old) tutorial-style example programs ?Öö Tiib
|       | |  `- Re: OpenSSL (old) tutorial-style example programs ?Scott Lurndal
|       | `* Re: OpenSSL (old) tutorial-style example programs ?Paavo Helde
|       |  `* Re: OpenSSL (old) tutorial-style example programs ?R.Wieser
|       |   `* Re: OpenSSL (old) tutorial-style example programs ?Paavo Helde
|       |    `- Re: OpenSSL (old) tutorial-style example programs ?R.Wieser
|       `* Re: OpenSSL (old) tutorial-style example programs ?Scott Lurndal
|        `- Re: OpenSSL (old) tutorial-style example programs ?R.Wieser
`- Re: OpenSSL (old) tutorial-style example programs ?Pavel

Pages:12
OpenSSL (old) tutorial-style example programs ?

<u4n3bk$3csb0$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=214&group=comp.lang.c%2B%2B#214

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: addr...@is.invalid (R.Wieser)
Newsgroups: comp.lang.c++
Subject: OpenSSL (old) tutorial-style example programs ?
Date: Thu, 25 May 2023 09:39:16 +0200
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <u4n3bk$3csb0$1@dont-email.me>
Injection-Date: Thu, 25 May 2023 07:39:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f34f5ee1de3e8998331ff24f11427892";
logging-data="3567968"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/PIIQazsdIMnDxqfXVuOUz9V0qupIFFqRNM/I3oTbyBQ=="
Cancel-Lock: sha1:a2w7opwxlKfX0qhoFS7rzlai3QI=
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512
X-Priority: 3
X-MSMail-Priority: Normal
X-RFC2646: Format=Flowed; Original
 by: R.Wieser - Thu, 25 May 2023 07:39 UTC

Hello all,

I've been trying whip up some code using (an older version of) OpenSSL.
I've ofcourse googled for information how to use it, but all I've been able
to find is some "examples" which stop directly after reading the reply (no
code to terminate the connection), or overly complex stuff aimed at a
certain target.

Currently I have got some code which shows :

1) a BIO_xxx way to retrieve unencrypted data

2) a mix between winsock and SSL_xxx to retrieve encrypted data - not sure
how/if the SSL part is closed

3) a mix between BIO_xxx and SSL_xxx to retrieve encrypted data, but which
doesn't include code to close the connection.

4) some other bits-and-pieces

The thing is, although I can mostly find the used commands back, I can't
find anything about how they interact. As such I have a hard time to even
find how to close an SSL connecion before I close the underlying BIO/socket
one. And for closing the BIO one I'm /assuming/ that all I need is
"BIO_free_all" ...

Also, 3) does stuff with BIO_xxx which caters to the SSL connection (like
setting the name of the target domain), while with 2) I only have to provide
the connected socket to SSL_set_fd to have everything work. IOW, I would
like to see some BIO_xxx code to connect (which it only seems to do on the
first BIO_read or BIO_write), and than have the SSL_xxx part take over the
connection the same way as with a standard socket.

One other thing : To keep my first steps as easy as possible I'm using
blocking sockets. Examples that jump into the deep end using async sockets
are of little value & use to me.

tl;dr:
I'm looking for some tutorial-style example code, explaining the basic
setup, request, retrieval and tear-down steps of an encrypted connection
using OpenSSL.

I'm currently using OpenSSL 0.9.8.0 , but that might just be because I've
not come across anything related to the current v3.1.0 version ...

Regards,
Rudy Wieser

Re: OpenSSL (old) tutorial-style example programs ?

<u4nk5a$3frh1$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=217&group=comp.lang.c%2B%2B#217

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: eesn...@osa.pri.ee (Paavo Helde)
Newsgroups: comp.lang.c++
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Date: Thu, 25 May 2023 15:26:17 +0300
Organization: A noiseless patient Spider
Lines: 122
Message-ID: <u4nk5a$3frh1$1@dont-email.me>
References: <u4n3bk$3csb0$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 25 May 2023 12:26:18 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="400c1e4b9ab7d4db4489a287c43d562e";
logging-data="3665441"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+pEMLzKsFGdOksKYWyxLXC1zAYfigum3g="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:o4hN1qWDDZzEieqVM4LMasK8bzo=
In-Reply-To: <u4n3bk$3csb0$1@dont-email.me>
Content-Language: en-US
 by: Paavo Helde - Thu, 25 May 2023 12:26 UTC

25.05.2023 10:39 R.Wieser kirjutas:
> Hello all,
>
> I've been trying whip up some code using (an older version of) OpenSSL.
> I've ofcourse googled for information how to use it, but all I've been able
> to find is some "examples" which stop directly after reading the reply (no
> code to terminate the connection), or overly complex stuff aimed at a
> certain target.
>
> Currently I have got some code which shows :
>
> 1) a BIO_xxx way to retrieve unencrypted data
>
> 2) a mix between winsock and SSL_xxx to retrieve encrypted data - not sure
> how/if the SSL part is closed
>
> 3) a mix between BIO_xxx and SSL_xxx to retrieve encrypted data, but which
> doesn't include code to close the connection.
>
> 4) some other bits-and-pieces
>
> The thing is, although I can mostly find the used commands back, I can't
> find anything about how they interact. As such I have a hard time to even
> find how to close an SSL connecion before I close the underlying BIO/socket
> one. And for closing the BIO one I'm /assuming/ that all I need is
> "BIO_free_all" ...
>
> Also, 3) does stuff with BIO_xxx which caters to the SSL connection (like
> setting the name of the target domain), while with 2) I only have to provide
> the connected socket to SSL_set_fd to have everything work. IOW, I would
> like to see some BIO_xxx code to connect (which it only seems to do on the
> first BIO_read or BIO_write), and than have the SSL_xxx part take over the
> connection the same way as with a standard socket.
>
> One other thing : To keep my first steps as easy as possible I'm using
> blocking sockets. Examples that jump into the deep end using async sockets
> are of little value & use to me.
>
> tl;dr:
> I'm looking for some tutorial-style example code, explaining the basic
> setup, request, retrieval and tear-down steps of an encrypted connection
> using OpenSSL.
>
> I'm currently using OpenSSL 0.9.8.0 , but that might just be because I've
> not come across anything related to the current v3.1.0 version ...

OpenSSL 0.9 is seriously out of date. Currently supported stable
versions are 1.1.* and 3.0.*.

I do not have polished example code, my actual code is scattered around
several C++ classes and in partially platform-dependent source files.
Anyway, I can paste some snippets here, maybe these are helpful.

This code is using OpenSSL 3.0.8 for wrapping an existing connected
client-side cocked into SSL (Linux and Windows):

// Set short socket read timeout for SSL_connect, to avoid indefinite
hanging
::setsockopt(socketHandle, SOL_SOCKET, SO_RCVTIMEO, // ...
platform-dependent code ...

// Create new SSL connection state object
if ((ssl_ = SSL_new(context_->GetSSL_CTX())) == nullptr) {
// handle error
}

// Set up SNI (Server Name Indication), some websites like Google
complain if this is not done.
SSL_set_tlsext_host_name(ssl_, host.c_str());

// Attach the SSL session to the socket descriptor
SSL_set_fd(ssl_, static_cast<int>(socketHandle));

// When using the SSL_connect(3) or SSL_accept(3) routines, calling of
SSL_set_connect_state() or SSL_set_accept_state() is not needed.

int ret = SSL_connect(ssl_);
if (ret == 1) {
// OK, connected
}

// set the socket timeout larger if needed ...

********* write ******

int n = SSL_write(ssl_, buf, static_cast<int>(len));
if (n != static_cast<int>(len)) {
// handle error

******* read *****

ERR_clear_error();
int n = SSL_read(ssl_, buf, static_cast<int>(len));
if (n < 0) {
// handle errpr
int k = SSL_get_error(ssl_, n);
if (k == SSL_ERROR_WANT_READ) {
// timeout, or maybe the server side closed connection?
// the caller should reconnect and retry
} else {
// handle other error
}
}

********* cleanup ********

if (socketHandle != INVALID_SOCKET) {
closesocket(socketHandle);
} if (ssl_) {
SSL_free(ssl_);
}

HTH

Re: OpenSSL (old) tutorial-style example programs ?

<u4nlls$3frh1$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=218&group=comp.lang.c%2B%2B#218

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: eesn...@osa.pri.ee (Paavo Helde)
Newsgroups: comp.lang.c++
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Date: Thu, 25 May 2023 15:52:12 +0300
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <u4nlls$3frh1$2@dont-email.me>
References: <u4n3bk$3csb0$1@dont-email.me> <u4nk5a$3frh1$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 25 May 2023 12:52:13 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="400c1e4b9ab7d4db4489a287c43d562e";
logging-data="3665441"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19bJ6PoQ/z1faTzLXrnpAkagyPxVemIx+c="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:6EIouzVZQcRlDZcEFUgUBt8fnlU=
In-Reply-To: <u4nk5a$3frh1$1@dont-email.me>
Content-Language: en-US
 by: Paavo Helde - Thu, 25 May 2023 12:52 UTC

25.05.2023 15:26 Paavo Helde kirjutas:
> 25.05.2023 10:39 R.Wieser kirjutas:
>> Hello all,
>>
>> I've been trying whip up some code using (an older version of) OpenSSL.
>> I've ofcourse googled for information how to use it, but all I've been
>> able
>> to find is some "examples" which stop directly after reading the reply
>> (no
>> code to terminate the connection), or overly complex stuff aimed at a
>> certain target.

BTW, ChatGPT4 seemed to be pretty strong with openssl, so you might just
ask it to generate some example programs. It even changed the code to
use proper std::unique_ptr lifetime management when I suggested that.

Re: OpenSSL (old) tutorial-style example programs ?

<u4nu3b$3ho7a$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=221&group=comp.lang.c%2B%2B#221

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Mutt...@dastardlyhq.com
Newsgroups: comp.lang.c++
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Date: Thu, 25 May 2023 15:15:55 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <u4nu3b$3ho7a$1@dont-email.me>
References: <u4n3bk$3csb0$1@dont-email.me> <u4nk5a$3frh1$1@dont-email.me>
Injection-Date: Thu, 25 May 2023 15:15:55 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="15bdb4579325c98d53d5a43d425f9a3f";
logging-data="3727594"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Z7fJCBKsoRIykCD5fOCaZ"
Cancel-Lock: sha1:Z3V2SJoY0HFsjbdOVEh6ZyjxTVs=
 by: Mutt...@dastardlyhq.com - Thu, 25 May 2023 15:15 UTC

On Thu, 25 May 2023 15:26:17 +0300
Paavo Helde <eesnimi@osa.pri.ee> wrote:
>25.05.2023 10:39 R.Wieser kirjutas:
>This code is using OpenSSL 3.0.8 for wrapping an existing connected
>client-side cocked into SSL (Linux and Windows):

I wouldn't use Windows socket code in Linux as windows sockets are severely
hobbled by not being able to be multiplexed on select() due to Microsofts
incomprehensible decision to make sockets a special handle type instead
of just a file descriptor meaning you can't mix them with other open file types
or inputs and they have to be converted into win messages or some such
overcomplicated crap in order to be received asynchronously unless you decide
to make life your even harder and spawn a new thread for each socket connection.

Re: OpenSSL (old) tutorial-style example programs ?

<u4o063$3icue$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=224&group=comp.lang.c%2B%2B#224

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: addr...@is.invalid (R.Wieser)
Newsgroups: comp.lang.c++
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Date: Thu, 25 May 2023 17:38:05 +0200
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <u4o063$3icue$1@dont-email.me>
References: <u4n3bk$3csb0$1@dont-email.me> <u4nk5a$3frh1$1@dont-email.me>
Injection-Date: Thu, 25 May 2023 15:51:31 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f34f5ee1de3e8998331ff24f11427892";
logging-data="3748814"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ZwHC1mm0VaK7JD4evWuN+ujQBiI26OTB+auSCYc97eQ=="
Cancel-Lock: sha1:sWSnzNN7iHwEDDIcDYMAOL7hDQ4=
X-MSMail-Priority: Normal
X-Priority: 3
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512
 by: R.Wieser - Thu, 25 May 2023 15:38 UTC

Paavo,

> OpenSSL 0.9 is seriously out of date. Currently supported stable versions
> are 1.1.* and 3.0.*.

Yeah, I know. I already downloaded v3.1.0. But up until I can find example
and/or tutorial code about/for it its rather useless to me. And as I could
find info about that "seriously out of date" version that became the one I'm
working with.

> This code is using OpenSSL 3.0.8 for wrapping an existing connected
> client-side cocked into SSL (Linux and Windows):

That is quite similar to the 2) code I mentioned (using a pre-created and
connected native socket). I would like to keep everything in OpenSSL.

I would like to see a solution where I can create and connect a BIO socket
in a similar way I create a native socket (not providing hostname
information) and than use the BIO socket in the code you have posted.

The other solution I'm looking for is a full SSL_xxx one. No BIO_xxx or
native socket.

By the way: you use "context_->GetSSL_CTX()", but I do not see you cleanup
the returned handle.

It /might/ be done by something else, and that is exacly what I meant where
I say that I can find reference to commands, but not how they interact.

For "SSL_free" I found this :
https://www.openssl.org/docs/man1.0.2/man3/SSL_free.html Under "remarks" it
says

[quote]
SSL_free() also calls the free()ing procedures for indirectly affected
items, if applicable: the buffering BIO, the read and write BIOs, cipher
lists specially created for this ssl, the SSL_SESSION.
[/quote]

If it refers to the above "GetSSL_CTX" handle they have it pretty-well
hidden. :-(

Last remark : a quick search on four search-engines for that "GetSSL_CTX"
function turns up exactly nothing ...

Regards,
Rudy Wieser

Re: OpenSSL (old) tutorial-style example programs ?

<u4o064$3icue$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=225&group=comp.lang.c%2B%2B#225

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: addr...@is.invalid (R.Wieser)
Newsgroups: comp.lang.c++
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Date: Thu, 25 May 2023 17:51:06 +0200
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <u4o064$3icue$2@dont-email.me>
References: <u4n3bk$3csb0$1@dont-email.me> <u4nk5a$3frh1$1@dont-email.me> <u4nu3b$3ho7a$1@dont-email.me>
Injection-Date: Thu, 25 May 2023 15:51:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f34f5ee1de3e8998331ff24f11427892";
logging-data="3748814"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX196hDQXeKZuIhTg8rt9gWwywFaLy2ha57OIRdhgNhzknQ=="
Cancel-Lock: sha1:ZBBwZ+eUAQ1JAFO3GqlUnRRRUCs=
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-Priority: 3
X-MSMail-Priority: Normal
 by: R.Wieser - Thu, 25 May 2023 15:51 UTC

Muttley,

> I wouldn't use Windows socket code in Linux

:-) I would not want to use it the other way around either.

But thats a quite big "what if" step you're making there - what makes you
think that I would want to do that ?

I think I asked how I could do the whole thing just using (BIO_xxx and)
SSL_xxx functions. Besides the "I need example code of the whole thing,
from setting up upto cleaning up" ofcourse.

On the other hand, for my blocking handles implementation I probably need a
"select" somewhere, so my code doesn't stall waiting forever for a
reply/more data while the other side is doing the same.

Regards,
Rudy Wieser

Re: OpenSSL (old) tutorial-style example programs ?

<u4o0ph$3ihcs$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=226&group=comp.lang.c%2B%2B#226

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Mutt...@dastardlyhq.com
Newsgroups: comp.lang.c++
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Date: Thu, 25 May 2023 16:01:54 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <u4o0ph$3ihcs$1@dont-email.me>
References: <u4n3bk$3csb0$1@dont-email.me> <u4nk5a$3frh1$1@dont-email.me> <u4nu3b$3ho7a$1@dont-email.me> <u4o064$3icue$2@dont-email.me>
Injection-Date: Thu, 25 May 2023 16:01:54 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="15bdb4579325c98d53d5a43d425f9a3f";
logging-data="3753372"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+0SlleN3ZqDdCUnlo6+aF6"
Cancel-Lock: sha1:k/crs17KURh+eFVQZapNGy+MgJk=
 by: Mutt...@dastardlyhq.com - Thu, 25 May 2023 16:01 UTC

On Thu, 25 May 2023 17:51:06 +0200
"R.Wieser" <address@is.invalid> wrote:
>Muttley,
>
>> I wouldn't use Windows socket code in Linux
>
>:-) I would not want to use it the other way around either.
>
>But thats a quite big "what if" step you're making there - what makes you
>think that I would want to do that ?

I don't care one way or the other, I was replying to Paavo, not you.

Re: OpenSSL (old) tutorial-style example programs ?

<pOLbM.485042$wfQc.457532@fx43.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=227&group=comp.lang.c%2B%2B#227

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx43.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Newsgroups: comp.lang.c++
References: <u4n3bk$3csb0$1@dont-email.me> <u4nk5a$3frh1$1@dont-email.me> <u4o063$3icue$1@dont-email.me>
Lines: 14
Message-ID: <pOLbM.485042$wfQc.457532@fx43.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 25 May 2023 16:13:09 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 25 May 2023 16:13:09 GMT
X-Received-Bytes: 1134
 by: Scott Lurndal - Thu, 25 May 2023 16:13 UTC

"R.Wieser" <address@is.invalid> writes:
>Paavo,
>
>> OpenSSL 0.9 is seriously out of date. Currently supported stable versions
>> are 1.1.* and 3.0.*.
>
>Yeah, I know. I already downloaded v3.1.0. But up until I can find example
>and/or tutorial code about/for it its rather useless to me. And as I could
>find info about that "seriously out of date" version that became the one I'm
>working with.

Have you a copy of the O'reilly openssl book?

There's a copy on github.

Re: OpenSSL (old) tutorial-style example programs ?

<u4o37b$3j1sc$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=228&group=comp.lang.c%2B%2B#228

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: eesn...@osa.pri.ee (Paavo Helde)
Newsgroups: comp.lang.c++
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Date: Thu, 25 May 2023 19:43:23 +0300
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <u4o37b$3j1sc$1@dont-email.me>
References: <u4n3bk$3csb0$1@dont-email.me> <u4nk5a$3frh1$1@dont-email.me>
<u4nu3b$3ho7a$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 25 May 2023 16:43:23 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="400c1e4b9ab7d4db4489a287c43d562e";
logging-data="3770252"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+0IWyp4nVKe1Kxo3DgKrTrh29Qovq+sVQ="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:U0drAGfnj/jPpslP95a/O6+h5RA=
Content-Language: en-US
In-Reply-To: <u4nu3b$3ho7a$1@dont-email.me>
 by: Paavo Helde - Thu, 25 May 2023 16:43 UTC

25.05.2023 18:15 Muttley@dastardlyhq.com kirjutas:
> On Thu, 25 May 2023 15:26:17 +0300
> Paavo Helde <eesnimi@osa.pri.ee> wrote:
>> 25.05.2023 10:39 R.Wieser kirjutas:
>> This code is using OpenSSL 3.0.8 for wrapping an existing connected
>> client-side cocked into SSL (Linux and Windows):
>
> I wouldn't use Windows socket code in Linux as windows sockets are severely
> hobbled by not being able to be multiplexed on select() due to Microsofts
> incomprehensible decision to make sockets a special handle type instead
> of just a file descriptor meaning you can't mix them with other open file types
> or inputs and they have to be converted into win messages or some such
> overcomplicated crap in order to be received asynchronously unless you decide
> to make life your even harder and spawn a new thread for each socket connection.

I agree life would be easier if I would only need to support UNIX
everything-is-a-file concepts. Alas, that's not the case for me.

BTW, the replacement of select() in Windows is WaitForMultipleObjects().
Windows messages are not needed (which is good because usually I have no
window which could receive them).

Anyway, sockets low-level programming is not a recommended approach.
Suggesting libcurl or Boost ASIO instead, which take care of some
aspects. OTOH, if things go south (read: corporate networks with
prescribed security regulations) it might be harder to get multiple
layers of software working, instead of a single layer.

Re: OpenSSL (old) tutorial-style example programs ?

<u4o4t4$3jo9r$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=229&group=comp.lang.c%2B%2B#229

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: eesn...@osa.pri.ee (Paavo Helde)
Newsgroups: comp.lang.c++
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Date: Thu, 25 May 2023 20:12:03 +0300
Organization: A noiseless patient Spider
Lines: 164
Message-ID: <u4o4t4$3jo9r$1@dont-email.me>
References: <u4n3bk$3csb0$1@dont-email.me> <u4nk5a$3frh1$1@dont-email.me>
<u4o063$3icue$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 25 May 2023 17:12:05 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="400c1e4b9ab7d4db4489a287c43d562e";
logging-data="3793211"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1929Sb3KMa24ColLmNPZR7vg9oOISfZ3AA="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:t9eqy84oTwS7xw9JaOt/BGbAYVk=
In-Reply-To: <u4o063$3icue$1@dont-email.me>
Content-Language: en-US
 by: Paavo Helde - Thu, 25 May 2023 17:12 UTC

25.05.2023 18:38 R.Wieser kirjutas:
> Paavo,
>
>> OpenSSL 0.9 is seriously out of date. Currently supported stable versions
>> are 1.1.* and 3.0.*.
>
> Yeah, I know. I already downloaded v3.1.0. But up until I can find example
> and/or tutorial code about/for it its rather useless to me. And as I could
> find info about that "seriously out of date" version that became the one I'm
> working with.
>
>> This code is using OpenSSL 3.0.8 for wrapping an existing connected
>> client-side cocked into SSL (Linux and Windows):
>
> That is quite similar to the 2) code I mentioned (using a pre-created and
> connected native socket). I would like to keep everything in OpenSSL.
>
> I would like to see a solution where I can create and connect a BIO socket
> in a similar way I create a native socket (not providing hostname
> information) and than use the BIO socket in the code you have posted.
>
> The other solution I'm looking for is a full SSL_xxx one. No BIO_xxx or
> native socket.

For client sockets I do not use any BIO* functions.

>
> By the way: you use "context_->GetSSL_CTX()", but I do not see you cleanup
> the returned handle.
>

Right. The GetSSL_CTX() is my own function which returns a pointer to
shared SSL_CTX structure. This SSL_CTX is created once, is shared by all
SSL client connections and will be released only at the end of the program.

Setting up this context involves loading the trusted CA certificates
from various locations, and setting up a verify callback which logs
errors or warning, but also verifies the certificate against the Windows
system cert store, on Windows.

I can list the functions I use for setting up and releasing this
SSL_CTX, in call order (error checks omitted for brevity):

SSL_library_init();
OpenSSL_add_all_algorithms();
SSL_load_error_strings();

const SSL_METHOD* method = TLS_client_method();
SSL_CTX* context = SSL_CTX_new(method);
SSL_CTX_set_default_verify_paths(context);

// These can be called 0 or more times
SSL_CTX_load_verify_file(context, trustedCaBundleFile.c_str());
SSL_CTX_load_verify_dir(context, trustedCaCertDir.c_str())

SSL_CTX_set_verify(context, SSL_VERIFY_PEER, MySSLVerifyCallback);

***** cleanup *********

SSL_CTX_free(context);

******** callback *************

NOTE: contains my own functions, you need to adapt creatively

int MySSLVerifyCallback(int preverify_ok, X509_STORE_CTX *x509_ctx) {
try {
if (preverify_ok) {
// openssl has verified the cert, OK.
return 1; // success
}

X509* err_cert = (x509_ctx?
X509_STORE_CTX_get_current_cert(x509_ctx): nullptr);
const char* errMessage;
int err;
if (x509_ctx) {
err = X509_STORE_CTX_get_error(x509_ctx);
errMessage = X509_verify_cert_error_string(err);
} else {
err = -1;
errMessage = "x509_ctx==nullptr";
}

// Verify the cert against the global Windows certificates store
(ACINF-3817).
if (VerifyTLS(err_cert)) {
return 1; // success
}

char buf[256] = { 0 };
if (err_cert) {
X509_NAME_oneline(X509_get_subject_name(err_cert), buf, sizeof(buf)
- 1);
}
std::string msg = Sprintf("SSL cert verify error: num=%d: %s:
%s")(err)(errMessage)(buf);
// handle as an error or as a warning
return 1; // success
return 0; // failure
} catch (...) {
// handle error
return 0; // failure
}
}

********** VerifyTLS() for Windows **************
NOTE: contains my own functions, you need to adapt creatively

// Need a separate function because OPENSSL_free is a macro.
void FreeOpenSslBuffer(unsigned char* buffer) {
OPENSSL_free(buffer);
}

bool VerifyTLS(X509* cert) {
// openssl failed to verify the cert.

// Try to verify the cert against Windows cert store
unsigned char* buffer = nullptr;
int len = i2d_X509(cert, &buffer);
if (len < 0) {
throw Exception(ERR_IO, "i2d_X509() failed");
}
ASSERT(buffer);
DEBUG_ASSERT(len > 0);
ON_BLOCK_EXIT(FreeOpenSslBuffer, buffer);

CERT_CHAIN_PARA thing;
::memset(&thing, 0, sizeof(thing));
thing.cbSize = sizeof(thing);
PCCERT_CONTEXT winContext =
::CertCreateCertificateContext(X509_ASN_ENCODING, buffer, len);
if (!winContext) {
syserr_t errorCode = GetLastErrorCode();
throw Exception(ERR_IO, "CertCreateCertificateContext() failed: " +
GetSysErrorString(errorCode));
}
ON_BLOCK_EXIT(::CertFreeCertificateContext, winContext);

PCCERT_CHAIN_CONTEXT chain = nullptr;
if (::CertGetCertificateChain(
nullptr,
winContext,
nullptr,
nullptr,
&thing,
CERT_CHAIN_CACHE_END_CERT|CERT_CHAIN_REVOCATION_CHECK_CACHE_ONLY,
nullptr,
&chain))
{
ON_BLOCK_EXIT(::CertFreeCertificateChain, chain);
DWORD errorStatus = chain->TrustStatus.dwErrorStatus;

if (errorStatus == 0) {
return true; // Windows approved the cert
}
}
return false;
}

Re: OpenSSL (old) tutorial-style example programs ?

<u4ocb6$3l0j9$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=232&group=comp.lang.c%2B%2B#232

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: addr...@is.invalid (R.Wieser)
Newsgroups: comp.lang.c++
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Date: Thu, 25 May 2023 21:18:37 +0200
Organization: A noiseless patient Spider
Lines: 74
Message-ID: <u4ocb6$3l0j9$1@dont-email.me>
References: <u4n3bk$3csb0$1@dont-email.me> <u4nk5a$3frh1$1@dont-email.me> <u4o063$3icue$1@dont-email.me> <u4o4t4$3jo9r$1@dont-email.me>
Injection-Date: Thu, 25 May 2023 19:19:02 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f34f5ee1de3e8998331ff24f11427892";
logging-data="3834473"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+XOj6d+NUOtk6Abtn/ApMclFYOc2ShCYQ9kwYhGF2RBw=="
Cancel-Lock: sha1:/PgLGH9nCqDycuK69iZ1Ux+YvuE=
X-MSMail-Priority: Normal
X-Priority: 3
X-RFC2646: Format=Flowed; Response
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512
 by: R.Wieser - Thu, 25 May 2023 19:18 UTC

Paavo,

> For client sockets I do not use any BIO* functions.

That still means you could be using either native or SSL_xxx sockets.

>> By the way: you use "context_->GetSSL_CTX()", but I do not see you
>> cleanup the returned handle.
>
> Right. The GetSSL_CTX() is my own function

That explains me not finding it, but also means that your offered code is of
the same level as most of what I can find on the web : incomplete, leaving
me guess to what else to get it to work is needed. :-\

> Setting up this context involves loading the trusted CA certificates from
> various locations,

Done,

> and setting up a verify callback which logs errors or warning,

The example I found uses "SSL_get_verify_result" .

Which makes me remember that I still need to find a demo domain which
purposely has a wrong cerificate - to test if the code I have actually
works.

> but also verifies the certificate against the Windows system cert store,
> on Windows.
PEM
Currently I'm using SSL_CTX_load_verify_locations, using a local file.

I might, in the future, try to find out how I can access Windows own cert
store for it, but as said I want to keep the current code as simple/basic as
possible.

> I can list the functions I use for setting up and releasing this SSL_CTX,
> in call order (error checks omitted for brevity):

I see a *lot* more code than I'm currently using myself. I can likely
write something with /around that, but it would just be a "monkey see,
monkey do" result - no real understanding of what I'm (effectivily) copying.
:-(

By the way, the below is what I started with. First a basic non-ssl
retrieval of a webpage, afterwards the same retrieval but now over SSL.

http://jokinkuang.github.io/2015/02/27/how_to_do_http_&_https_request_with_openssl.html

As you can see it does most everything with BIO_xxx calls, with just a
sliver of SSL_xxx related calls thrown in.

This one

https://gist.githubusercontent.com/endSly/8369715/raw/ee86f381e814499bdffd34267b5e371b21839ecb/sslconnect.c

uses a native socket, connects it and than gives it to the SSL_xxx layer.
There is no "BIO_set_conn_hostname" (or an SSL_xxx version of it!) in sight
anywhere, but it seems to work nonwithstanding (probably extracting the
domain name and port from the native socket)

I've got a number of other snippets, but as I said, most are incomplete or
(far) beyond a basic setup. Like this one (which has thrown a number of
snippets on a single page):

https://cpp.hotexamples.com/examples/-/-/SSL_connect/cpp-ssl_connect-function-examples.html

Regards,
Rudy Wieser

Re: OpenSSL (old) tutorial-style example programs ?

<87mt1syvdt.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=233&group=comp.lang.c%2B%2B#233

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c++
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Date: Thu, 25 May 2023 14:05:34 -0700
Organization: None to speak of
Lines: 29
Message-ID: <87mt1syvdt.fsf@nosuchdomain.example.com>
References: <u4n3bk$3csb0$1@dont-email.me> <u4nk5a$3frh1$1@dont-email.me>
<u4o063$3icue$1@dont-email.me> <pOLbM.485042$wfQc.457532@fx43.iad>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="4a85f0e3a74f0f16e65bb89724e15350";
logging-data="3866316"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+nGHlnvDb6RfVyK/dOLB/e"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:tmDUwVLo+kDf6/GNAo4w36k5YaA=
sha1:FpJsTMh2aCQ8xW5foX/RyPFT1LQ=
 by: Keith Thompson - Thu, 25 May 2023 21:05 UTC

scott@slp53.sl.home (Scott Lurndal) writes:
> "R.Wieser" <address@is.invalid> writes:
>>Paavo,
>>
>>> OpenSSL 0.9 is seriously out of date. Currently supported stable versions
>>> are 1.1.* and 3.0.*.
>>
>>Yeah, I know. I already downloaded v3.1.0. But up until I can find example
>>and/or tutorial code about/for it its rather useless to me. And as I could
>>find info about that "seriously out of date" version that became the one I'm
>>working with.
>
> Have you a copy of the O'reilly openssl book?
>
> There's a copy on github.

Do you mean "Network Security with OpenSSL" by John Viega, Matt Messier,
and Pravir Chandra? The last update was June 2002, when the latest
release was 0.9.7d.

I found a PDF copy of the book on GitHub. It appears to be pirated.

O'Reilly sometimes releases some books for free, but they haven't done
so with this one.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: OpenSSL (old) tutorial-style example programs ?

<u4oito$3m1bg$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=235&group=comp.lang.c%2B%2B#235

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: eesn...@osa.pri.ee (Paavo Helde)
Newsgroups: comp.lang.c++
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Date: Fri, 26 May 2023 00:11:20 +0300
Organization: A noiseless patient Spider
Lines: 72
Message-ID: <u4oito$3m1bg$1@dont-email.me>
References: <u4n3bk$3csb0$1@dont-email.me> <u4nk5a$3frh1$1@dont-email.me>
<u4o063$3icue$1@dont-email.me> <u4o4t4$3jo9r$1@dont-email.me>
<u4ocb6$3l0j9$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 25 May 2023 21:11:20 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="91b06b957e31d9c3a1ae0d75b187b81e";
logging-data="3868016"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/0VqgYHDfF66CMccNuxKhH1XAibvtK3D8="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:0v2CTZ9zZ8m8BY59zhTFOdPeY9s=
In-Reply-To: <u4ocb6$3l0j9$1@dont-email.me>
Content-Language: en-US
 by: Paavo Helde - Thu, 25 May 2023 21:11 UTC

25.05.2023 22:18 R.Wieser kirjutas:
> Paavo,
>
>> For client sockets I do not use any BIO* functions.
>
> That still means you could be using either native or SSL_xxx sockets.

I'm using a native socket created by the C socket() call.

>
>>> By the way: you use "context_->GetSSL_CTX()", but I do not see you
>>> cleanup the returned handle.
>>
>> Right. The GetSSL_CTX() is my own function
>
> That explains me not finding it, but also means that your offered code is of
> the same level as most of what I can find on the web : incomplete, leaving
> me guess to what else to get it to work is needed. :-\

Right. Nobody has said life should be easy ;-) Also, nobody has paid me
to prepare code examples which would exactly suit your needs.

>
>> Setting up this context involves loading the trusted CA certificates from
>> various locations,
>
> Done,
>
>> and setting up a verify callback which logs errors or warning,
>
> The example I found uses "SSL_get_verify_result" .
>
> Which makes me remember that I still need to find a demo domain which
> purposely has a wrong cerificate - to test if the code I have actually
> works.
>
>> but also verifies the certificate against the Windows system cert store,
>> on Windows.
> PEM
> Currently I'm using SSL_CTX_load_verify_locations, using a local file.
>
> I might, in the future, try to find out how I can access Windows own cert
> store for it, but as said I want to keep the current code as simple/basic as
> possible.

You just snipped the code which you maybe will try to figure out in the
future.

>
>> I can list the functions I use for setting up and releasing this SSL_CTX,
>> in call order (error checks omitted for brevity):
>
> I see a *lot* more code than I'm currently using myself. I can likely
> write something with /around that, but it would just be a "monkey see,
> monkey do" result - no real understanding of what I'm (effectivily) copying.
> :-(

Well, that's how it tends to be.

For openssl functions, you can at least just google "man FUNCTIONNAME"
to get the man page.

Of course, it does not help openssl contains hundreds of functions, half
of which are deprecated, and half of which are not needed for the task
at hand.

If one feels uncomfortable with raw sockets and raw openssl, one can use
some higher level interface like libcurl, or maybe Python. If I would
need to write this functionality again, I would probably use libcurl.

Re: OpenSSL (old) tutorial-style example programs ?

<u4pls3$3tkls$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=236&group=comp.lang.c%2B%2B#236

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: addr...@is.invalid (R.Wieser)
Newsgroups: comp.lang.c++
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Date: Fri, 26 May 2023 09:07:19 +0200
Organization: A noiseless patient Spider
Lines: 104
Message-ID: <u4pls3$3tkls$1@dont-email.me>
References: <u4n3bk$3csb0$1@dont-email.me> <u4nk5a$3frh1$1@dont-email.me> <u4o063$3icue$1@dont-email.me> <u4o4t4$3jo9r$1@dont-email.me> <u4ocb6$3l0j9$1@dont-email.me> <u4oito$3m1bg$1@dont-email.me>
Injection-Date: Fri, 26 May 2023 07:07:47 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="60ffb7b87c8b5a71b9c11f1c97469d3d";
logging-data="4117180"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Ua1nFOvXLNeRHk7n1m31TeYcsZPbJmbojL0nH5B1XjA=="
Cancel-Lock: sha1:q7MgYPe6vdEQ2vfU5bEMPzqGBa4=
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512
X-RFC2646: Format=Flowed; Response
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-MSMail-Priority: Normal
X-Priority: 3
 by: R.Wieser - Fri, 26 May 2023 07:07 UTC

Paavo,

> I'm using a native socket created by the C socket() call.

I've got one bit of code using a native socket (ws2_32.dll). But it what I
would like to be able to do without. Just OpenSSL calls - preferrably just
SSL_xxx family calls, but opening a simple native socket using BIO_xxx would
be acceptable (iow : not using the BIO_new_ssl_connect and related ones).

> Right. Nobody has said life should be easy ;-)

Whut ?! I'm sure I've said that a few times in the past .... :-p

> Also, nobody has paid me to prepare code examples which would exactly suit
> your needs.

I can't vouch for that, but it is why I started this thread. I can google
snippets of OpenSSL code easily. The problem for me is learning how they
work - so that I have a fighting chance to combine them in new, interresting
ways.

Did I already mention that I'm a hobby programmer, who, as part of that
hobby, doesn't have a problem with spending time on trying to figure stuff
out ? Well, I am and I don't. :-)

> You just snipped the code which you maybe will try to figure out in the
> future.

I just stored the code samples which mention doing that for future use, in
current favor of some of the more basic code samples.

Though in this particular case there is a "maybe" involved. There is a good
chance that I will try to keep the whole thing self-contained. On the other
hand, there is also a good chance that I will make the use of that external
storage available depending on a (commandline) setting.

> For openssl functions, you can at least just google "man FUNCTIONNAME" to
> get the man page.

Thats what I've been pretty-much doing, and finding stuff like

https://www.openssl.org/docs/man1.1.1/man3/SSL_connect.html

That site seems to be a nice source for function reference. But just take a
look at the difference of information between the blocking and non-blocking
usage (remember that I mentioned that I'm using, for starters,using the
simpler "blocking" mode ?).

Another one :

https://www.openssl.org/docs/manmaster/man3/SSL_set_fd.html

Its good enough when you want to look up something (looking back), but isn't
as good when you need a usage explanation (looking forward).

Ahhh.... I already wondered why I have been using SSL_set_fd and BIO_get_fd
(digging down to the native socket), while not having seen anything which
loads the BIO directly into the SSL context.

It turns out that that function actually exists : SSL_set_bio. Now all I
have to do is to spend (heaps of) time googeling for that function, in the
hope I can find some code using it (showing how the BIO needs to be
created).

> Of course, it does not help openssl contains hundreds of functions, half
> of which are deprecated, and half of which are not needed for the task at
> hand.

:-) You noticed. ssleay32.dll has (just) 206. libeay32.dll has a whopping
2953 of them.

Yeah, thats part of the problem I'm having with OpenSSL. It seems to have
multiple ways of reaching the same goal (take BIO_read and SSL_read. No
real idea when either is (in)valid to use), and than finding examples which
mix the different methods does not help me in getting the big picture. :-|

> If one feels uncomfortable with raw sockets

I've got no problem with that (see below).

> and raw openssl,

And that is what I would like to do - but *not* mixing raw sockets up with
"raw" OpenSSL.

Although I have code available which does all of the "raw" / native socket
handling (parsing the host : port combination, resolving the host to an IP,
connecting to that IP and port), I cannot escape the feeling that
/somewhere/ in that humongous ammount of ssleay32 and libay32 functions
there must be functions which offer the same - but than in a simpler
package.

Actually, BIO_set_conn_hostname does the parsing just fine, but not at the
level I would like to see it happening (using the SSL_xxx environment).

By the way : I posted here because this is where I expected the most chance
of getting a "low level" answer (the "comp.lang.c" newsgroup seems to have
been poisonned by spammers). I'm actually using an Assembler (Borlands
Tasm32), which goes even lower than that. :-)

Regards,
Rudy Wieser

Re: OpenSSL (old) tutorial-style example programs ?

<u4r567$332h$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=250&group=comp.lang.c%2B%2B#250

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: eesn...@osa.pri.ee (Paavo Helde)
Newsgroups: comp.lang.c++
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Date: Fri, 26 May 2023 23:35:18 +0300
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <u4r567$332h$1@dont-email.me>
References: <u4n3bk$3csb0$1@dont-email.me> <u4nk5a$3frh1$1@dont-email.me>
<u4o063$3icue$1@dont-email.me> <u4o4t4$3jo9r$1@dont-email.me>
<u4ocb6$3l0j9$1@dont-email.me> <u4oito$3m1bg$1@dont-email.me>
<u4pls3$3tkls$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 26 May 2023 20:35:19 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="52a8244d333060584c46c4c28615c0da";
logging-data="101457"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/D2ReuyGZg2SasxU/5OPa4b3MWTjRHEDg="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:PcCdKtlSjCSO2CTlpF+vA55s6l8=
In-Reply-To: <u4pls3$3tkls$1@dont-email.me>
Content-Language: en-US
 by: Paavo Helde - Fri, 26 May 2023 20:35 UTC

26.05.2023 10:07 R.Wieser kirjutas:

> I can't vouch for that, but it is why I started this thread. I can google
> snippets of OpenSSL code easily. The problem for me is learning how they
> work - so that I have a fighting chance to combine them in new, interresting
> ways.

Suggesting you to post these questions to the openssl-users@openssl.org
mailing list (subscribe at
https://mta.openssl.org/mailman/listinfo/openssl-users), there are
people who know infinitely more about openssl than myself. If your use
case is not the exact same than mine then I'm afraid I can not be of
much help.

Re: OpenSSL (old) tutorial-style example programs ?

<lQecM.627310$Lfzc.522975@fx36.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=251&group=comp.lang.c%2B%2B#251

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx36.iad.POSTED!not-for-mail
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Newsgroups: comp.lang.c++
References: <u4n3bk$3csb0$1@dont-email.me>
From: pauldont...@removeyourself.dontspam.yahoo (Pavel)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.15
MIME-Version: 1.0
In-Reply-To: <u4n3bk$3csb0$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 61
Message-ID: <lQecM.627310$Lfzc.522975@fx36.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Sat, 27 May 2023 03:31:29 UTC
Date: Fri, 26 May 2023 23:31:15 -0400
X-Received-Bytes: 3180
 by: Pavel - Sat, 27 May 2023 03:31 UTC

R.Wieser wrote:
> Hello all,
>
> I've been trying whip up some code using (an older version of) OpenSSL.
> I've ofcourse googled for information how to use it, but all I've been able
> to find is some "examples" which stop directly after reading the reply (no
> code to terminate the connection), or overly complex stuff aimed at a
> certain target.
>
> Currently I have got some code which shows :
>
> 1) a BIO_xxx way to retrieve unencrypted data
>
> 2) a mix between winsock and SSL_xxx to retrieve encrypted data - not sure
> how/if the SSL part is closed
>
> 3) a mix between BIO_xxx and SSL_xxx to retrieve encrypted data, but which
> doesn't include code to close the connection.
>
> 4) some other bits-and-pieces
>
> The thing is, although I can mostly find the used commands back, I can't
> find anything about how they interact. As such I have a hard time to even
> find how to close an SSL connecion before I close the underlying BIO/socket
> one.
SSL_shutdown (ideally, in a loop where you try it till it returns 1 (if
it returns 0, wait for the socket to be selected for read and do
SSL_read when it is)), then SSL_free, then close(socket)
And for closing the BIO one I'm /assuming/ that all I need is
> "BIO_free_all" ...
>
> Also, 3) does stuff with BIO_xxx which caters to the SSL connection (like
> setting the name of the target domain), while with 2) I only have to provide
> the connected socket to SSL_set_fd to have everything work. IOW, I would
> like to see some BIO_xxx code to connect (which it only seems to do on the
> first BIO_read or BIO_write), and than have the SSL_xxx part take over the
> connection the same way as with a standard socket.
>
> One other thing : To keep my first steps as easy as possible I'm using
> blocking sockets. Examples that jump into the deep end using async sockets
> are of little value & use to me.
>
> tl;dr:
> I'm looking for some tutorial-style example code, explaining the basic
> setup, request, retrieval and tear-down steps of an encrypted connection
> using OpenSSL.
The best tutorial-style code I could recommend is the one from the
Chapter 8 of "SSL and TLS" of Eric Rescorla. The book is great
otherwise, too, so highly recommend.

>
> I'm currently using OpenSSL 0.9.8.0 , but that might just be because I've
> not come across anything related to the current v3.1.0 version ...
>
> Regards,
> Rudy Wieser
>
>

HTH
-Pavel

Re: OpenSSL (old) tutorial-style example programs ?

<u4sa6h$b8gp$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=252&group=comp.lang.c%2B%2B#252

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: addr...@is.invalid (R.Wieser)
Newsgroups: comp.lang.c++
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Date: Sat, 27 May 2023 09:04:48 +0200
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <u4sa6h$b8gp$1@dont-email.me>
References: <u4n3bk$3csb0$1@dont-email.me> <u4nk5a$3frh1$1@dont-email.me> <u4o063$3icue$1@dont-email.me> <u4o4t4$3jo9r$1@dont-email.me> <u4ocb6$3l0j9$1@dont-email.me> <u4oito$3m1bg$1@dont-email.me> <u4pls3$3tkls$1@dont-email.me> <u4r567$332h$1@dont-email.me>
Injection-Date: Sat, 27 May 2023 07:06:57 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a9884c2aaf3f33f187490cd18cf5c723";
logging-data="369177"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18RGXN6iSRTCIR+LoDlY2yh6nk4WIm7nj9l/78eBpJArA=="
Cancel-Lock: sha1:asU/47koL79HPwzu9Agu5SCECdk=
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Response
X-Priority: 3
 by: R.Wieser - Sat, 27 May 2023 07:04 UTC

Paavo,

> Suggesting you to post these questions to the openssl-users@openssl.org
> mailing list (subscribe at
> https://mta.openssl.org/mailman/listinfo/openssl-users),

Thanks for that.

Sigh. Yet another mailing list which I need to subscribe to just to get an
answer to a basic question - and which I will than probably leave
afterwards.

> If your use case is not the exact same than mine then I'm afraid I can not
> be of much help.

I do not have a use case yet (just a vague one, which can change on a dime).
All I'm curently doing is try to figure out the easiest way (code and usage
wise) to set up an SSL connection [read some test data] and tear it down
afterwards. Thats all.

Or, said otherwise : I'm a bottom-up programmer. The above is the basic
bottom layer. The layers placed ontop of that will give direction to what
its going to be used for.

Currently one of my vague use-cases is to retrieve HTTP (over SSL) data - as
that seems to be the easiest next step. Nicely synchronous and all that.

Regards,
Rudy Wieser

Re: OpenSSL (old) tutorial-style example programs ?

<u4scm3$bi8g$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=253&group=comp.lang.c%2B%2B#253

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: eesn...@osa.pri.ee (Paavo Helde)
Newsgroups: comp.lang.c++
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Date: Sat, 27 May 2023 10:49:23 +0300
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <u4scm3$bi8g$1@dont-email.me>
References: <u4n3bk$3csb0$1@dont-email.me> <u4nk5a$3frh1$1@dont-email.me>
<u4o063$3icue$1@dont-email.me> <u4o4t4$3jo9r$1@dont-email.me>
<u4ocb6$3l0j9$1@dont-email.me> <u4oito$3m1bg$1@dont-email.me>
<u4pls3$3tkls$1@dont-email.me> <u4r567$332h$1@dont-email.me>
<u4sa6h$b8gp$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 27 May 2023 07:49:23 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="781b6736d023d2facc1793d67f756f3b";
logging-data="379152"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19UabforM8wUx63mWusxgxwl22VIZVUleg="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:fMiA3aTqiSP9DlAnMSn5VC2LdrY=
Content-Language: en-US
In-Reply-To: <u4sa6h$b8gp$1@dont-email.me>
 by: Paavo Helde - Sat, 27 May 2023 07:49 UTC

27.05.2023 10:04 R.Wieser kirjutas:
> Paavo,
>
>> Suggesting you to post these questions to the openssl-users@openssl.org
>> mailing list (subscribe at
>> https://mta.openssl.org/mailman/listinfo/openssl-users),
>
> Thanks for that.
>
> Sigh. Yet another mailing list which I need to subscribe to just to get an
> answer to a basic question - and which I will than probably leave
> afterwards.

Recently they tried to shut down the mailing list, citing the same
reasons as you, but there was a serious backlash as many members
declared they love the mailing list format and would not use any online
forums.

They also have wiki with some example programs like
https://wiki.openssl.org/index.php/SSL/TLS_Client , have you studied
these already?

Re: OpenSSL (old) tutorial-style example programs ?

<u4t04t$e82q$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=255&group=comp.lang.c%2B%2B#255

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: addr...@is.invalid (R.Wieser)
Newsgroups: comp.lang.c++
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Date: Sat, 27 May 2023 15:21:23 +0200
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <u4t04t$e82q$1@dont-email.me>
References: <u4n3bk$3csb0$1@dont-email.me> <u4nk5a$3frh1$1@dont-email.me> <u4o063$3icue$1@dont-email.me> <u4o4t4$3jo9r$1@dont-email.me> <u4ocb6$3l0j9$1@dont-email.me> <u4oito$3m1bg$1@dont-email.me> <u4pls3$3tkls$1@dont-email.me> <u4r567$332h$1@dont-email.me> <u4sa6h$b8gp$1@dont-email.me> <u4scm3$bi8g$1@dont-email.me>
Injection-Date: Sat, 27 May 2023 13:21:33 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a9884c2aaf3f33f187490cd18cf5c723";
logging-data="467034"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/sHn5xGt+O9EWpYL3CR8Qxj6NuetdfumFJWmPiS6DdGA=="
Cancel-Lock: sha1:KRftfaANus2x5B5dsub1Zek/4E8=
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512
X-MSMail-Priority: Normal
X-RFC2646: Format=Flowed; Response
X-Priority: 3
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
 by: R.Wieser - Sat, 27 May 2023 13:21 UTC

Paavo,

> Recently they tried to shut down the mailing list, citing the same reasons
> as you, but there was a serious backlash as many members declared they
> love the mailing list format

I can understand that love. I just don't share it.

> and would not use any online forums.

I don't either, for the same reason as as those mailing lists.

Newsgroups are my only exception to it, mainly because it combines a lot of
different knowledge groups.

> They also have wiki with some example programs like
> https://wiki.openssl.org/index.php/SSL/TLS_Client , have you studied these
> already?

Nope, not that one. And its yet another way to to do the same thing - and
again more complex than needed. On the other hand, it does have some
explanation. :-)

Than again, did you know that "BIO_do_connect" is actually a #define of the
command below it :

] #define BIO_do_connect(b) BIO_do_handshake(b)

At least, according to the documentation I've got here.

IOW, no idea why its done twice ...

Also, the latter one is again a #define of doing a BIO_ctrl with a
BIO_C_DO_STATEMACHINE argument.

.... and those libeay32 and ssleay32DLLs /still/ have 3000+ functions in
them. :-)

Regards,
Rudy Wieser

Re: OpenSSL (old) tutorial-style example programs ?

<BGocM.254900$LAYb.176836@fx02.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=256&group=comp.lang.c%2B%2B#256

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx02.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Newsgroups: comp.lang.c++
References: <u4n3bk$3csb0$1@dont-email.me> <u4nk5a$3frh1$1@dont-email.me> <u4o063$3icue$1@dont-email.me> <u4o4t4$3jo9r$1@dont-email.me> <u4ocb6$3l0j9$1@dont-email.me> <u4oito$3m1bg$1@dont-email.me> <u4pls3$3tkls$1@dont-email.me> <u4r567$332h$1@dont-email.me> <u4sa6h$b8gp$1@dont-email.me>
Lines: 16
Message-ID: <BGocM.254900$LAYb.176836@fx02.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Sat, 27 May 2023 14:43:45 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Sat, 27 May 2023 14:43:45 GMT
X-Received-Bytes: 1357
 by: Scott Lurndal - Sat, 27 May 2023 14:43 UTC

"R.Wieser" <address@is.invalid> writes:
>Paavo,
>
>> Suggesting you to post these questions to the openssl-users@openssl.org
>> mailing list (subscribe at
>> https://mta.openssl.org/mailman/listinfo/openssl-users),
>
>Thanks for that.
>
>Sigh. Yet another mailing list which I need to subscribe to just to get an
>answer to a basic question - and which I will than probably leave
>afterwards.

Have you tried your local library? Perhaps they have a copy of
the O'reilly book on OpenSSL you can check out?

Re: OpenSSL (old) tutorial-style example programs ?

<xMocM.254901$LAYb.188002@fx02.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=257&group=comp.lang.c%2B%2B#257

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx02.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Newsgroups: comp.lang.c++
References: <u4n3bk$3csb0$1@dont-email.me> <u4nk5a$3frh1$1@dont-email.me> <u4o063$3icue$1@dont-email.me> <u4o4t4$3jo9r$1@dont-email.me> <u4ocb6$3l0j9$1@dont-email.me> <u4oito$3m1bg$1@dont-email.me> <u4pls3$3tkls$1@dont-email.me> <u4r567$332h$1@dont-email.me> <u4sa6h$b8gp$1@dont-email.me> <u4scm3$bi8g$1@dont-email.me> <u4t04t$e82q$1@dont-email.me>
Lines: 20
Message-ID: <xMocM.254901$LAYb.188002@fx02.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Sat, 27 May 2023 14:50:05 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Sat, 27 May 2023 14:50:05 GMT
X-Received-Bytes: 1540
 by: Scott Lurndal - Sat, 27 May 2023 14:50 UTC

"R.Wieser" <address@is.invalid> writes:
>Paavo,
>
>> Recently they tried to shut down the mailing list, citing the same reasons
>> as you, but there was a serious backlash as many members declared they
>> love the mailing list format
>

>
>... and those libeay32 and ssleay32DLLs /still/ have 3000+ functions in
>them. :-)

Not surprising given that openssl is a general purpose cryptographic
toolkit, supporting dozens of crypto algorithms both symmetric
and asymmetric along with multiple transports (TLS1, TLS2), digital
signatures, secure hashs, et alia.

An opensource version of bsafe.

https://en.wikipedia.org/wiki/BSAFE

Re: OpenSSL (old) tutorial-style example programs ?

<u4t9sf$fi2i$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=258&group=comp.lang.c%2B%2B#258

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: eesn...@osa.pri.ee (Paavo Helde)
Newsgroups: comp.lang.c++
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Date: Sat, 27 May 2023 19:07:42 +0300
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <u4t9sf$fi2i$1@dont-email.me>
References: <u4n3bk$3csb0$1@dont-email.me> <u4nk5a$3frh1$1@dont-email.me>
<u4o063$3icue$1@dont-email.me> <u4o4t4$3jo9r$1@dont-email.me>
<u4ocb6$3l0j9$1@dont-email.me> <u4oito$3m1bg$1@dont-email.me>
<u4pls3$3tkls$1@dont-email.me> <u4r567$332h$1@dont-email.me>
<u4sa6h$b8gp$1@dont-email.me> <u4scm3$bi8g$1@dont-email.me>
<u4t04t$e82q$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 27 May 2023 16:07:43 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="781b6736d023d2facc1793d67f756f3b";
logging-data="510034"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX188MhI5uDPGmloKk0r8R1DEutrEN3lvbKw="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:/RJhzp4ibWyH3FQsbTR6UXEjC0Y=
Content-Language: en-US
In-Reply-To: <u4t04t$e82q$1@dont-email.me>
 by: Paavo Helde - Sat, 27 May 2023 16:07 UTC

27.05.2023 16:21 R.Wieser kirjutas:
> Paavo,

>> They also have wiki with some example programs like
>> https://wiki.openssl.org/index.php/SSL/TLS_Client , have you studied these
>> already?
>
> Nope, not that one. And its yet another way to to do the same thing - and
> again more complex than needed. On the other hand, it does have some
> explanation. :-)

At first glance, it's as simple as it can get. Openssl is a pretty
low-level library, so its usage cannot be very short. If you want
one-liner access, use Python.

> Than again, did you know that "BIO_do_connect" is actually a #define of the
> command below it :

My IDE tells me that whenever I'm inclined to be interested in such things.

Regards
Paavo

Re: OpenSSL (old) tutorial-style example programs ?

<u4v2vj$pu2o$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=265&group=comp.lang.c%2B%2B#265

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: addr...@is.invalid (R.Wieser)
Newsgroups: comp.lang.c++
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Date: Sun, 28 May 2023 09:27:16 +0200
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <u4v2vj$pu2o$1@dont-email.me>
References: <u4n3bk$3csb0$1@dont-email.me> <u4nk5a$3frh1$1@dont-email.me> <u4o063$3icue$1@dont-email.me> <u4o4t4$3jo9r$1@dont-email.me> <u4ocb6$3l0j9$1@dont-email.me> <u4oito$3m1bg$1@dont-email.me> <u4pls3$3tkls$1@dont-email.me> <u4r567$332h$1@dont-email.me> <u4sa6h$b8gp$1@dont-email.me> <BGocM.254900$LAYb.176836@fx02.iad>
Injection-Date: Sun, 28 May 2023 08:22:11 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="674458ac5eb53040a4e0ffcb23180b52";
logging-data="850008"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19zYd74NHwqWr7O3LBgxguHUNrz8XAwnQGMSx+Jfbflkw=="
Cancel-Lock: sha1:xosVAUxppS7kWem1cZMl02IH4+I=
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512
X-MSMail-Priority: Normal
X-RFC2646: Format=Flowed; Original
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-Priority: 3
 by: R.Wieser - Sun, 28 May 2023 07:27 UTC

Scott,

> Have you tried your local library? Perhaps they have a copy of
> the O'reilly book on OpenSSL ...

Thanks, I did not even think of that. Than again, my local libraries are
not known to carry much of this kind of stuff. But I sure could take a
peek.

> ... you can check out?

Same problem I'm afraid. My subscription ended a few decades ago, and
starting another one just for a single bit of info simply isn't my thing.

Though the difference is that a library still allows you, even without a
membership card, to browse books and even photocopy a few pages outof them.
:-)

Regards,
Rudy Wieser

Re: OpenSSL (old) tutorial-style example programs ?

<u4v2vj$pu2o$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=266&group=comp.lang.c%2B%2B#266

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: addr...@is.invalid (R.Wieser)
Newsgroups: comp.lang.c++
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Date: Sun, 28 May 2023 09:58:02 +0200
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <u4v2vj$pu2o$2@dont-email.me>
References: <u4n3bk$3csb0$1@dont-email.me> <u4nk5a$3frh1$1@dont-email.me> <u4o063$3icue$1@dont-email.me> <u4o4t4$3jo9r$1@dont-email.me> <u4ocb6$3l0j9$1@dont-email.me> <u4oito$3m1bg$1@dont-email.me> <u4pls3$3tkls$1@dont-email.me> <u4r567$332h$1@dont-email.me> <u4sa6h$b8gp$1@dont-email.me> <u4scm3$bi8g$1@dont-email.me> <u4t04t$e82q$1@dont-email.me> <xMocM.254901$LAYb.188002@fx02.iad>
Injection-Date: Sun, 28 May 2023 08:22:11 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="674458ac5eb53040a4e0ffcb23180b52";
logging-data="850008"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19GE5cSoWdVB+3ON8uifB2Sksd91V5p7omRD7xG5k3ptA=="
Cancel-Lock: sha1:EcRs5nokKa3uAXXK0QEWZMEf9BI=
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512
X-MSMail-Priority: Normal
X-RFC2646: Format=Flowed; Original
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-Priority: 3
 by: R.Wieser - Sun, 28 May 2023 07:58 UTC

Scott,

>>... and those libeay32 and ssleay32DLLs /still/ have 3000+ functions in
>>them. :-)
>
> Not surprising given that openssl is a general purpose cryptographic
> toolkit,

Ofcourse. That is why its called "OpenCrypt", and not "OpenSSL".

Oh, wait ... :-p

Regards,
Rudy Wieser

Re: OpenSSL (old) tutorial-style example programs ?

<u4v2vk$pu2o$3@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=267&group=comp.lang.c%2B%2B#267

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: addr...@is.invalid (R.Wieser)
Newsgroups: comp.lang.c++
Subject: Re: OpenSSL (old) tutorial-style example programs ?
Date: Sun, 28 May 2023 10:21:38 +0200
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <u4v2vk$pu2o$3@dont-email.me>
References: <u4n3bk$3csb0$1@dont-email.me> <u4nk5a$3frh1$1@dont-email.me> <u4o063$3icue$1@dont-email.me> <u4o4t4$3jo9r$1@dont-email.me> <u4ocb6$3l0j9$1@dont-email.me> <u4oito$3m1bg$1@dont-email.me> <u4pls3$3tkls$1@dont-email.me> <u4r567$332h$1@dont-email.me> <u4sa6h$b8gp$1@dont-email.me> <u4scm3$bi8g$1@dont-email.me> <u4t04t$e82q$1@dont-email.me> <u4t9sf$fi2i$1@dont-email.me>
Injection-Date: Sun, 28 May 2023 08:22:12 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="674458ac5eb53040a4e0ffcb23180b52";
logging-data="850008"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18pKqBNL0N9HftRAx6QmrMYn0/QlqLSBzXojeIxOy9gQA=="
Cancel-Lock: sha1:RVYOaEW2btzMYx31/8NJ2TQ9gSQ=
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Response
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512
X-MSMail-Priority: Normal
 by: R.Wieser - Sun, 28 May 2023 08:21 UTC

Paavo,

> At first glance, it's as simple as it can get. Openssl is a pretty
> low-level library, so its usage cannot be very short.

Lol ? I'm an Assembly programmer. Parsing a simple domain:port string
and than connecting to it needs a /lot/ of code. Way more than the
"BIO_set_conn_hostname". :-)

> If you want one-liner access, use Python.

If I would have wanted that I would not still be an Assembly programmer. I
however /do/ try to find the simpelest way

No, the biggest problem I have is seeing, within two DLLs, multiple ways to
do the same. Which, in my book, is /not/ a good thing. Especially not
when they can (but should not?) be mixed up.

As I said before, I tend to work from the minimal code needed to do the job,
and than, if needed, add some bells and whistles. Experience has learned
me not to attempt to do it the other way around. It creates way to many
opportunities to get confused and be left with non-working, or worse, badly
working code.

>> Than again, did you know that "BIO_do_connect" is actually a #define of
>> the
>> command below it :
>
> My IDE tells me that whenever I'm inclined to be interested in such
> things.

And you're mostly not interested, as long as it works, right ? And by
that missing that two, directly following each other functions seem to be
doing the same thing ...

I did notice, and am now wondering why. And if that should not have
happened, how much I should trust the correctness of the rest of the code.
:-(

Regards,
Rudy Wieser


devel / comp.lang.c++ / OpenSSL (old) tutorial-style example programs ?

Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor