mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
Add qhelp
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
class Bad extends WebViewClient {
|
||||
// BAD: All certificates are trusted.
|
||||
public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error) { // $hasResult
|
||||
handler.proceed();
|
||||
}
|
||||
}
|
||||
|
||||
class Good extends WebViewClient {
|
||||
PublicKey myPubKey = ...;
|
||||
|
||||
// GOOD: Only certificates signed by a certain public key are trusted.
|
||||
public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error) { // $hasResult
|
||||
try {
|
||||
X509Certificate cert = error.getCertificate().getX509Certificate();
|
||||
cert.verify(this.myPubKey);
|
||||
handler.proceed();
|
||||
}
|
||||
catch (CertificateException|NoSuchAlgorithmException|InvalidKeyException|NoSuchProviderException|SignatureException e) {
|
||||
handler.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user