Fix ClassCastException in TrustClientHelper (#2033)