randombit / botan

Cryptography Toolkit
https://botan.randombit.net
BSD 2-Clause "Simplified" License
2.6k stars 570 forks source link

How to properly use TLS related API #941

Open ksanderon opened 7 years ago

ksanderon commented 7 years ago

Introduction

Hello, I'm trying to add in rili project wrapper for tls/ssl layer over my network service implementation(it's just tcp/ip). Unfortunately I have some questions regarding how to use botan-2 properly, which are not answered explicite(or I oversight it) by documentation/manual, github issues nor code which I found in implementation of botan cli application :/

Of course these questions probably could be answered "somehow" by google, however I don't like "stackoverflow copy paste programming style" and hope it's better to ask than live with bad informations ;)

Real questions

randombit commented 7 years ago

Sorry I had missed seeing this, totally legit questions here I think. Which I will work on providing good answers to when time permits and perhaps even update the docs accordingly. For now -

If I will call explicite Botan::TLS::Client/Server::close when I may assume that botan will not ask to send more data to peer, so when underlying connection can be cleanly closed?

When close is called, you may get one final callback to send the (possibly encrypted) alert message to the peer. That callback will occur before close returns.

What should be done if mentioned in manual scenario will occur? These alerts should be just discarded or there should be introduced some kind of special actions?

They cannot just be discarded because all implementations can and will send alerts before authentication to indicate some problem that prevents the handshake from succeeding. It is not possible (without out of band data) to know if a handshake_failure alert means a MITM attacker is selectively blocking your TLS handshakes from succeeding, or if there is simply some misconfiguration or other problem. But how to respond to this is going to be very application specific.