JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.
If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.
If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.
| CodeSonar® 27.0w | AdaCore Inc |
A method that performs certificate validation never throws a CertificateException.
A method is considered to perform certificate validation if it's annotated with @com.juliasoft.julia.checkers.unsafeConnection.ChecksPrincipalTrust.
| Class Name | Use of Insecure verify for Certificate (Java) | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Significance | security | ||||||||||||
| Mnemonic | JAVA.INSEC.CVU | ||||||||||||
| Categories |
|
||||||||||||
| Availability | Available for Java only. Android Only. Warnings of this class will only be reported in Android code: that is, code that uses the Android API. |
||||||||||||
| Enabling | Checks for this warning class are enabled by
default. To disable them, add the following WARNING_FILTER rule to the
project configuration file.
WARNING_FILTER += discard class="Use of Insecure verify for Certificate (Java)" |
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.X509TrustManager;
public class InsecureTrustManager {
// A trust manager whose check methods never throw accepts any certificate,
// including forged or untrusted ones.
static X509TrustManager trustAny() {
return new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
// empty: never rejects a client certificate
}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
// 'Use of Insecure verify for Certificate (Java)' warning issued here
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
};
}
}
To reproduce this example, analyze it with the following configuration:
JAVA_ANALYSIS_ENTRY_POINTS_MODE = ALL_METHODS # This warning class is modeled only by the Android framework, so the example # is analyzed with the Android runtime rather than a plain Java one. JAVA_ANALYSIS_FRAMEWORK = androidAPI35
The following configuration file parameters affect checks for this warning class.
To report problems with this documentation, please visit https://support.adacore.com/csm.