@@ -176,6 +176,14 @@ void selfSigned() {
176176 "java.io.IOException: PKIX path building failed: " +
177177 "sun.security.provider.certpath.SunCertPathBuilderException: " +
178178 "unable to find valid certification path to requested target" );
179+
180+
181+
182+
183+ }
184+
185+ @ Test
186+ void selfSignedWorksIfDisabled () {
179187 disableSsl ();
180188 canCall ("https://self-signed.badssl.com/" );
181189 }
@@ -214,11 +222,15 @@ private void disableSsl() {
214222 }
215223
216224 private void failsAsync (String url , Class <? extends Throwable > exClass , String error ) {
217- Exception e = assertThrows (Exception .class , () -> Unirest .get (url ).asEmptyAsync ().get ());
218- if (!e .getCause ().getClass ().isAssignableFrom (exClass )) {
219- fail ("Expected wrong exception type \n Expected: " + exClass + "\n but got " + e .getCause ().getClass ());
225+ try {
226+ var e = Unirest .get (url ).asEmptyAsync ().get ().getParsingError ().get ().getCause ().getCause ();
227+ if (!e .getCause ().getClass ().isAssignableFrom (exClass )) {
228+ fail ("Expected wrong exception type \n Expected: " + exClass + "\n but got " + e .getCause ().getClass ());
229+ }
230+ assertEquals (error , e .getMessage (), "Wrong Error Message" );
231+ } catch (Exception e ) {
232+ throw new RuntimeException (e );
220233 }
221- assertEquals (error , e .getMessage (), "Wrong Error Message" );
222234 }
223235
224236 private void fails (String url , Class <? extends Throwable > exClass , String error ) {
0 commit comments