Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssl_options() option inside tls() #457

Merged
merged 5 commits into from Jun 24, 2015
Merged

Conversation

pasztor
Copy link
Contributor

@pasztor pasztor commented Apr 8, 2015

allowed values: no-sslv2, no-sslv3, no-tlsv1, no-tlsv11, no-tlsv12, none
I think, they are self-explanatory.

Signed-off-by: PÁSZTOR György gyorgy.pasztor@balabit.com

PÁSZTOR György added 3 commits April 8, 2015 11:00
allowed values: no-sslv2, no-sslv3, no-tlsv1, no-tlsv11, no-tlsv12, none
I think, they are self-explanatory.

Signed-off-by: PÁSZTOR György <gyorgy.pasztor@balabit.com>
* GList *l -> Glist *option
* handle if tls library does not know SSL_OP_NO_TLSv1_2.
* I put into the same block the handling of SSL_OP_NO_TLSv1_1, since they appeared at the same time ssl: 1.0.0->1.0.1
* removed comment

Signed-off-by: PÁSZTOR György <gyorgy.pasztor@balabit.com>
* option change back to l, since that is an iterater. See bazsi's comment
* remove the "none" option. if we want an empty set instead of no-sslv2, then we can write ssl_options() which also means an empty set. So, based on this, we do not need the "none" keyword. however, recent ssl libraries does not allow sslv2, even if we do not set the SSL_OP_NO_SSLv2 option.

Signed-off-by: PÁSZTOR György <gyorgy.pasztor@balabit.com>
@deirf
Copy link

deirf commented May 5, 2015

👍

TSO_NOTLSv11=0x0008,
TSO_NOTLSv12=0x0010,
} TLSSslOptions;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You use TlsSslOption as a flag, but the type of it is enumeration.
Enumerations are usually used for unique values, not for combinations of these.
I mean, that you should "typedef unsigned int TlsSslOptions" and declare the TSO_* as define (e.g.: #define TSO_NOSSLv2 1)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would slightly disagree. Enums are available in a debugger while defines
are not.
On May 20, 2015 4:55 PM, "juhaszviktor" notifications@github.com wrote:

In lib/tlscontext.h
#457 (comment):

@@ -44,6 +44,16 @@ typedef enum
TVM_REQUIRED=0x0020,
} TLSVerifyMode;

+typedef enum
+{

  • TSO_NONE,
  • TSO_NOSSLv2=0x0001,
  • TSO_NOSSLv3=0x0002,
  • TSO_NOTLSv1=0x0004,
  • TSO_NOTLSv11=0x0008,
  • TSO_NOTLSv12=0x0010,
    +} TLSSslOptions;

You use TlsSslOption as a flag, but the type of it is enumeration.
Enumerations are usually used for unique values, not for combinations of
these.
I mean, that you should "typedef unsigned int TlsSslOptions" and declare
the TSO_* as define (e.g.: #define TSO_NOSSLv2 1)


Reply to this email directly or view it on GitHub
https://github.com/balabit/syslog-ng/pull/457/files#r30710623.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can agree your standpoint, but if I look at the whole syslog-ng code, the flags and some kind of options are declared as a define. For example in logwriter.h LW_* and LWO_* are also defines.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And what if we have a typedef for TlsSslOption and static const TlsSslOption delarations for the values? Or we just change the return type of tls_lookup_options to int...

I think the problem with enum is that when we return from tls_lookup_options we say that type of the value is TLSSslOptions but it's not: it`s a combination of the enumerated values.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a number of this calls were converted to enums recently. I did start to
move to the enum direction. An example is TLSVerifyMode just above this
declaration. Or msg-format.h, or a number of others. So this is not
consistent. I do know that I was converting a couple of these.

In these cases the call sites do not use the enum type (I don't even see
the use for the typedef itself, that should be abandoned), the the
call-sites should use "int"

Bazsi

On Wed, May 20, 2015 at 8:09 PM, juhaszviktor notifications@github.com
wrote:

In lib/tlscontext.h
#457 (comment):

@@ -44,6 +44,16 @@ typedef enum
TVM_REQUIRED=0x0020,
} TLSVerifyMode;

+typedef enum
+{

  • TSO_NONE,
  • TSO_NOSSLv2=0x0001,
  • TSO_NOSSLv3=0x0002,
  • TSO_NOTLSv1=0x0004,
  • TSO_NOTLSv11=0x0008,
  • TSO_NOTLSv12=0x0010,
    +} TLSSslOptions;

I can agree your standpoint, but if I look at the whole syslog-ng code,
the flags and some kind of options are declared as a define. For example in
logwriter.h LW_* and LWO_* are also defines.


Reply to this email directly or view it on GitHub
https://github.com/balabit/syslog-ng/pull/457/files#r30731421.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, then we can keep enum, eliminate typedef and just use an int as return type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to be consequent with the solution what was already there for the verify options. I did pretty much the same.
If my solution is bad, then verify options's is bad too.
If you'd like, I'd gladly correct both of them, but I think that should be a scope of a different PR, and this PR should focus only to implement the ssl-options() setting.
Opinions?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi,

I'm reluctant to merge the patch in this form.
Please, use int as return type, as I suggested before (and you can keep enum... ).

L.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi,

as I said: this is consistent with the other parts from the same module in this form.
I also said, that I agree with you about the typedef enum part.
So, I am wondering if

  • you do not trust my word, that I will make a code cleaning for this module where I fix the ssl-options and the verify-mode both
  • or you want a code where two very-very similar functions (tls_lookup_verify_mode, tls_lookup_options) are defined two different ways in the same code
  • or you want a larger patch, where a code cleanup is done at the same branch where a new function/ option is implemented?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi,

I told you IRL that this is not about consistency: it's about correctness.
(a legacy code will always contain some legacy code ;-) That doesn't mean we should always follow it
and doesn't mean that it cannot be changed... )

I think 2nd option in your list would be fine with an additional note:
If we have a chance for writing a not-legacy code, we should have to do that, IMHO.

L.

coding style fixation as jviktor asked

lib/tlscontext.h:
try to be consequent with verify_mode
so TLSSslOptions goes into gint inside the TLSContext struct

Signed-off-by: PÁSZTOR György <gyorgy.pasztor@balabit.com>
@@ -280,6 +280,7 @@ tls_context_setup_session(TLSContext *self)
SSL *ssl;
TLSSession *session;
gint ssl_error;
long ssl_options;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know no reason why this option should be long.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just say only one: Manual page SSL_CTX_set_options(3ssl)
SYNOPSIS
#include <openssl/ssl.h>

    long SSL_CTX_set_options(SSL_CTX *ctx, long options);

That internal variable is for prepare the value what SSL_CTX_set_options will get.
Is that satisfactory enough? ;-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely. :)

* tls_lookup_options return type is gint now, as lbudai asked
* TLSSslOptions is not typedef-ed now, it's just an enum now

Signed-off-by: PÁSZTOR György <gyorgy.pasztor@balabit.com>
@lbudai
Copy link
Collaborator

lbudai commented Jun 24, 2015

Thanks!!

lbudai added a commit that referenced this pull request Jun 24, 2015
ssl_options() option inside tls()
@lbudai lbudai merged commit acf4339 into syslog-ng:master Jun 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants