mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-17 03:14:03 +02:00
Ignore SSL verification option added (#175)
* add configuration to ignore SS verification
This commit is contained in:
@@ -36,6 +36,11 @@ public abstract class AbstractHTMLRipper extends AbstractRipper {
|
|||||||
|
|
||||||
protected AbstractHTMLRipper(URL url) throws IOException {
|
protected AbstractHTMLRipper(URL url) throws IOException {
|
||||||
super(url);
|
super(url);
|
||||||
|
if(Utils.getConfigBoolean("ssl.verify.off",false)){
|
||||||
|
Http.SSLVerifyOff();
|
||||||
|
}else {
|
||||||
|
Http.undoSSLVerifyOff();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract String getDomain();
|
protected abstract String getDomain();
|
||||||
|
@@ -95,6 +95,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
private static JCheckBox configAutoupdateCheckbox;
|
private static JCheckBox configAutoupdateCheckbox;
|
||||||
private static JComboBox<String> configLogLevelCombobox;
|
private static JComboBox<String> configLogLevelCombobox;
|
||||||
private static JCheckBox configURLHistoryCheckbox;
|
private static JCheckBox configURLHistoryCheckbox;
|
||||||
|
private static JCheckBox configSSLVerifyOff;
|
||||||
private static JCheckBox configPlaySound;
|
private static JCheckBox configPlaySound;
|
||||||
private static JCheckBox configSaveOrderCheckbox;
|
private static JCheckBox configSaveOrderCheckbox;
|
||||||
private static JCheckBox configShowPopup;
|
private static JCheckBox configShowPopup;
|
||||||
@@ -212,6 +213,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
Utils.setConfigBoolean("descriptions.save", configSaveDescriptions.isSelected());
|
Utils.setConfigBoolean("descriptions.save", configSaveDescriptions.isSelected());
|
||||||
Utils.setConfigBoolean("prefer.mp4", configPreferMp4.isSelected());
|
Utils.setConfigBoolean("prefer.mp4", configPreferMp4.isSelected());
|
||||||
Utils.setConfigBoolean("remember.url_history", configURLHistoryCheckbox.isSelected());
|
Utils.setConfigBoolean("remember.url_history", configURLHistoryCheckbox.isSelected());
|
||||||
|
Utils.setConfigBoolean("ssl.verify.off", configSSLVerifyOff.isSelected());
|
||||||
Utils.setConfigString("lang", configSelectLangComboBox.getSelectedItem().toString());
|
Utils.setConfigString("lang", configSelectLangComboBox.getSelectedItem().toString());
|
||||||
saveWindowPosition(mainFrame);
|
saveWindowPosition(mainFrame);
|
||||||
saveHistory();
|
saveHistory();
|
||||||
@@ -565,6 +567,8 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
true);
|
true);
|
||||||
configURLHistoryCheckbox = addNewCheckbox(Utils.getLocalizedString("remember.url.history"),
|
configURLHistoryCheckbox = addNewCheckbox(Utils.getLocalizedString("remember.url.history"),
|
||||||
"remember.url_history", true);
|
"remember.url_history", true);
|
||||||
|
configSSLVerifyOff = addNewCheckbox(Utils.getLocalizedString("ssl.verify.off"),
|
||||||
|
"ssl.verify.off", false);
|
||||||
configUrlFileChooserButton = new JButton(Utils.getLocalizedString("download.url.list"));
|
configUrlFileChooserButton = new JButton(Utils.getLocalizedString("download.url.list"));
|
||||||
|
|
||||||
configLogLevelCombobox = new JComboBox<>(
|
configLogLevelCombobox = new JComboBox<>(
|
||||||
@@ -599,6 +603,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
addItemToConfigGridBagConstraints(gbc, idx++, configClipboardAutorip, configSaveAlbumTitles);
|
addItemToConfigGridBagConstraints(gbc, idx++, configClipboardAutorip, configSaveAlbumTitles);
|
||||||
addItemToConfigGridBagConstraints(gbc, idx++, configSaveDescriptions, configPreferMp4);
|
addItemToConfigGridBagConstraints(gbc, idx++, configSaveDescriptions, configPreferMp4);
|
||||||
addItemToConfigGridBagConstraints(gbc, idx++, configWindowPosition, configURLHistoryCheckbox);
|
addItemToConfigGridBagConstraints(gbc, idx++, configWindowPosition, configURLHistoryCheckbox);
|
||||||
|
addItemToConfigGridBagConstraints(gbc, idx++, configSSLVerifyOff, configSSLVerifyOff);
|
||||||
addItemToConfigGridBagConstraints(gbc, idx++, configSelectLangComboBox, configUrlFileChooserButton);
|
addItemToConfigGridBagConstraints(gbc, idx++, configSelectLangComboBox, configUrlFileChooserButton);
|
||||||
addItemToConfigGridBagConstraints(gbc, idx++, configSaveDirLabel, configSaveDirButton);
|
addItemToConfigGridBagConstraints(gbc, idx++, configSaveDirLabel, configSaveDirButton);
|
||||||
|
|
||||||
@@ -738,6 +743,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
configPreferMp4.setText(Utils.getLocalizedString("prefer.mp4.over.gif"));
|
configPreferMp4.setText(Utils.getLocalizedString("prefer.mp4.over.gif"));
|
||||||
configWindowPosition.setText(Utils.getLocalizedString("restore.window.position"));
|
configWindowPosition.setText(Utils.getLocalizedString("restore.window.position"));
|
||||||
configURLHistoryCheckbox.setText(Utils.getLocalizedString("remember.url.history"));
|
configURLHistoryCheckbox.setText(Utils.getLocalizedString("remember.url.history"));
|
||||||
|
configSSLVerifyOff.setText(Utils.getLocalizedString("ssl.verify.off"));
|
||||||
optionLog.setText(Utils.getLocalizedString("Log"));
|
optionLog.setText(Utils.getLocalizedString("Log"));
|
||||||
optionHistory.setText(Utils.getLocalizedString("History"));
|
optionHistory.setText(Utils.getLocalizedString("History"));
|
||||||
optionQueue.setText(Utils.getLocalizedString("queue"));
|
optionQueue.setText(Utils.getLocalizedString("queue"));
|
||||||
@@ -1012,6 +1018,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
addCheckboxListener(configSaveLogs, "log.save");
|
addCheckboxListener(configSaveLogs, "log.save");
|
||||||
addCheckboxListener(configSaveURLsOnly, "urls_only.save");
|
addCheckboxListener(configSaveURLsOnly, "urls_only.save");
|
||||||
addCheckboxListener(configURLHistoryCheckbox, "remember.url_history");
|
addCheckboxListener(configURLHistoryCheckbox, "remember.url_history");
|
||||||
|
addCheckboxListener(configSSLVerifyOff, "ssl.verify.off");
|
||||||
addCheckboxListener(configSaveAlbumTitles, "album_titles.save");
|
addCheckboxListener(configSaveAlbumTitles, "album_titles.save");
|
||||||
addCheckboxListener(configSaveDescriptions, "descriptions.save");
|
addCheckboxListener(configSaveDescriptions, "descriptions.save");
|
||||||
addCheckboxListener(configPreferMp4, "prefer.mp4");
|
addCheckboxListener(configPreferMp4, "prefer.mp4");
|
||||||
|
@@ -13,11 +13,14 @@ import org.jsoup.HttpStatusException;
|
|||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
|
|
||||||
|
import javax.net.ssl.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -230,4 +233,43 @@ public class Http {
|
|||||||
}
|
}
|
||||||
throw new IOException("Failed to load " + url + " after " + this.retries + " attempts", lastException);
|
throw new IOException("Failed to load " + url + " after " + this.retries + " attempts", lastException);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SSLVerifyOff() {
|
||||||
|
try {
|
||||||
|
TrustManager[] trustAllCerts = new TrustManager[]{
|
||||||
|
new X509TrustManager() {
|
||||||
|
public X509Certificate[] getAcceptedIssuers() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkClientTrusted(X509Certificate[] certs, String authType) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkServerTrusted(X509Certificate[] certs, String authType) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
SSLContext sslContext = SSLContext.getInstance("SSL");
|
||||||
|
sslContext.init(null, trustAllCerts, new SecureRandom());
|
||||||
|
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
|
||||||
|
HostnameVerifier allHostsValid = (hostname, session) -> true;
|
||||||
|
HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("ignoreSSLVerification() failed.");
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void undoSSLVerifyOff() {
|
||||||
|
try {
|
||||||
|
// Reset to the default SSL socket factory and hostname verifier
|
||||||
|
SSLContext sslContext = SSLContext.getInstance("SSL");
|
||||||
|
sslContext.init(null, null, new SecureRandom());
|
||||||
|
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
|
||||||
|
HttpsURLConnection.setDefaultHostnameVerifier(HttpsURLConnection.getDefaultHostnameVerifier());
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("undoSSLVerificationIgnore() failed.");
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,6 +26,7 @@ save.descriptions = Save descriptions
|
|||||||
prefer.mp4.over.gif = Prefer MP4 over GIF
|
prefer.mp4.over.gif = Prefer MP4 over GIF
|
||||||
restore.window.position = Restore window position
|
restore.window.position = Restore window position
|
||||||
remember.url.history = Remember URL history
|
remember.url.history = Remember URL history
|
||||||
|
ssl.verify.off = SSL verify off
|
||||||
loading.history.from = Loading history from
|
loading.history.from = Loading history from
|
||||||
|
|
||||||
# Queue keys
|
# Queue keys
|
||||||
|
Reference in New Issue
Block a user