[cryptography] "best practices" for hostname validation when using JSSE

Tim Dierks tim at dierks.org
Fri Aug 9 15:49:07 EDT 2013

I added a comment on your Stack Overflow post (incorrectly closed, IMHO,
but the SO crowd can be prickly).

The right thing to do depends on knowing a couple more details:
 1. Where are you getting your certificates?
 2. What's the best way to name the servers you trust?

Since you have a proprietary protocol, the easiest thing to do is make sure
the cert chains up to a root you trust (ideally not system-installed roots,
because nobody knows how deep the sewage flows there—the only exception
would be if you want to delegate trust issues to a user of your software
who might be expected to manage their own trustpoints using system
configuration tools, but that gives me the willies). Then make sure the
name on the cert matches the name of who you think you're communicating
with (could be DNS name, or some other identification of the entity); if
you may want to use SSL libraries which check certs and which are designed
for HTTPS, you probably want to use the DNS name.

I don't know enough about JSSE-specific implementation to be able to give
you a precise answer.

 - Tim

On Fri, Aug 9, 2013 at 3:03 PM, Patrick Pelletier
<code at funwithsoftware.org>wrote:

> One thing mentioned in the "Most Dangerous Code in the World" paper (and
> I've verified experimentally) is that JSSE doesn't validate the hostname
> against the X.509 certificate, so if one uses JSSE naively, one is open to
> man-in-the-middle attacks.  The best solution I've been able to figure out
> is to "borrow" the hostname validation code from Apache HttpComponents.
>  But I'm curious what other people who use JSSE are doing, and if there's a
> "best practice" for doing this.
> Apologies if this isn't on-topic for this list; I know you guys mostly
> discuss higher-level issues, rather than APIs.  I already tried asking on
> Stack Overflow, and they said it was off-topic for Stack Overflow:
> http://stackoverflow.com/questions/18139448/how-should-i-do-hostname-validation-when-using-jsse
> So, a meta-question would be: where is the right place to ask this
> question?  I haven't been able to find a JSSE-specific mailing list.
> Thanks,
> --Patrick
> _______________________________________________
> cryptography mailing list
> cryptography at randombit.net
> http://lists.randombit.net/mailman/listinfo/cryptography
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.randombit.net/pipermail/cryptography/attachments/20130809/a1480145/attachment-0001.html>

More information about the cryptography mailing list