MB-10953 Fix certificate validation with R16.

There used to be a bug in both R14 and R15 that resulted in valid and
valid_peer events not being passed to verification function. See
https://github.com/erlang/otp/commit/25b2354cc9bcf09c87dc65526936e976fe95d3fd
for details.

When this got fixed in R16, our certificate validation stopped
working. So I added handling of valid and valid_peer.

Change-Id: I5051bd9f6aecc0fe82fe31815c586095812f4137
Reviewed-on: http://review.couchbase.org/36307
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Artem Stemkovski <artem@couchbase.com>