On Wed, Nov 29, 2017 at 01:44:01PM +0000, wizard2010@xxxxxxxxx wrote: > > > > int verify_callback (int ok, X509_STORE_CTX *ctx) > > > > { > > > > printf("Verification callback OK!\n"); > > > > return 1; > > > > } > > > > ... > > > > SSL_CTX_set_verify(ssl_server_ctx, SSL_VERIFY_PEER | > > > > SSL_VERIFY_FAIL_IF_NO_PEER_CERT, dtls_verify_callback); > > > > The above completely disables authentication of the peer certificate, > > and makes your application vulnerable to man-in-the-middle attacks. > > Perhaps that's OK, but often it is not. > > Why did you say that code disable the authentication? Because it is true. Your verification callback overrides all certificate verification failures by unconditionally returning "1" for success, regardless of the "ok" value, or the error status in the X509_STORE_CTX. > One thing that I didn't understand is what type of verification is made on > SSL_CTX_set_verify function. Clearly not, so you need to either find some documentation that makes it clear to you (manpages, examples in other code, a book, ...) or not use that feature. Calling functions whose meaning you do not understand is a bad idea, especially in security-related code. > And what is supposed/right thing to do on verify_callback in order to > perform the client certificate authentication? The right thing normally is not have a callback at all. Or always return the passed-in "ok" value, but log some information about the certificate chain and any errors reported. In rare situations you might choose to ignore very specific error conditions, but getting that right requries a deeper understanding of the implications. -- Viktor. -- openssl-users mailing list To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users