coova / jradius

JRadius is a Java RADIUS framework for client and server.
Other
92 stars 92 forks source link

Add support for server certificate authenticity verification #24

Open Sovietaced opened 6 years ago

Sovietaced commented 6 years ago

Reviewer: @wlanmac

This addresses part of my concern raised in https://github.com/coova/jradius/issues/23 I personally only have use for EAP-TTLS so I have no need to send client certificates.

In short, this performs server certificate verification upon receipt of a certificate during the handshake when a valid X509TrustManager can be found. In order to verify the server certificate dynamically I had to pass the key exchange algorithm into the trust manager. I extended the KeyExchange interface and created enum values instead of static integers. This allows the enum to hold a name string as well as the integer value. The name string is what is passed to the trust manager dynamically.

I also made some changes to how the KeyUsage object was constructed in the KeyExchange implementations since I was getting an IllegalArgumentException during testing. I updated some of the bouncy castle classes so that I could leverage KeyUsage.fromExtensions. This seemed to alleviate the problem.