Skip to content

Commit

Permalink
Ignore SSL verification option added (#175)
Browse files Browse the repository at this point in the history
* add configuration to ignore SS verification
  • Loading branch information
joroto authored Jan 1, 2025
1 parent 6487219 commit 255e388
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public abstract class AbstractHTMLRipper extends AbstractRipper {

protected AbstractHTMLRipper(URL url) throws IOException {
super(url);
if(Utils.getConfigBoolean("ssl.verify.off",false)){
Http.SSLVerifyOff();
}else {
Http.undoSSLVerifyOff();
}
}

protected abstract String getDomain();
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/com/rarchives/ripme/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
private static JCheckBox configAutoupdateCheckbox;
private static JComboBox<String> configLogLevelCombobox;
private static JCheckBox configURLHistoryCheckbox;
private static JCheckBox configSSLVerifyOff;
private static JCheckBox configPlaySound;
private static JCheckBox configSaveOrderCheckbox;
private static JCheckBox configShowPopup;
Expand Down Expand Up @@ -212,6 +213,7 @@ private void shutdownCleanup() {
Utils.setConfigBoolean("descriptions.save", configSaveDescriptions.isSelected());
Utils.setConfigBoolean("prefer.mp4", configPreferMp4.isSelected());
Utils.setConfigBoolean("remember.url_history", configURLHistoryCheckbox.isSelected());
Utils.setConfigBoolean("ssl.verify.off", configSSLVerifyOff.isSelected());
Utils.setConfigString("lang", configSelectLangComboBox.getSelectedItem().toString());
saveWindowPosition(mainFrame);
saveHistory();
Expand Down Expand Up @@ -565,6 +567,8 @@ public void setValueAt(Object value, int row, int col) {
true);
configURLHistoryCheckbox = addNewCheckbox(Utils.getLocalizedString("remember.url.history"),
"remember.url_history", true);
configSSLVerifyOff = addNewCheckbox(Utils.getLocalizedString("ssl.verify.off"),
"ssl.verify.off", false);
configUrlFileChooserButton = new JButton(Utils.getLocalizedString("download.url.list"));

configLogLevelCombobox = new JComboBox<>(
Expand Down Expand Up @@ -599,6 +603,7 @@ public void setValueAt(Object value, int row, int col) {
addItemToConfigGridBagConstraints(gbc, idx++, configClipboardAutorip, configSaveAlbumTitles);
addItemToConfigGridBagConstraints(gbc, idx++, configSaveDescriptions, configPreferMp4);
addItemToConfigGridBagConstraints(gbc, idx++, configWindowPosition, configURLHistoryCheckbox);
addItemToConfigGridBagConstraints(gbc, idx++, configSSLVerifyOff, configSSLVerifyOff);
addItemToConfigGridBagConstraints(gbc, idx++, configSelectLangComboBox, configUrlFileChooserButton);
addItemToConfigGridBagConstraints(gbc, idx++, configSaveDirLabel, configSaveDirButton);

Expand Down Expand Up @@ -738,6 +743,7 @@ private void changeLocale() {
configPreferMp4.setText(Utils.getLocalizedString("prefer.mp4.over.gif"));
configWindowPosition.setText(Utils.getLocalizedString("restore.window.position"));
configURLHistoryCheckbox.setText(Utils.getLocalizedString("remember.url.history"));
configSSLVerifyOff.setText(Utils.getLocalizedString("ssl.verify.off"));
optionLog.setText(Utils.getLocalizedString("Log"));
optionHistory.setText(Utils.getLocalizedString("History"));
optionQueue.setText(Utils.getLocalizedString("queue"));
Expand Down Expand Up @@ -1012,6 +1018,7 @@ public void mouseClicked(MouseEvent e) {
addCheckboxListener(configSaveLogs, "log.save");
addCheckboxListener(configSaveURLsOnly, "urls_only.save");
addCheckboxListener(configURLHistoryCheckbox, "remember.url_history");
addCheckboxListener(configSSLVerifyOff, "ssl.verify.off");
addCheckboxListener(configSaveAlbumTitles, "album_titles.save");
addCheckboxListener(configSaveDescriptions, "descriptions.save");
addCheckboxListener(configPreferMp4, "prefer.mp4");
Expand Down Expand Up @@ -1528,8 +1535,8 @@ private synchronized void handleEvent(StatusEvent evt) {
}
/*
* content key %path% the path to the album folder %url% is the album url
*
*
*
*
*/
if (Utils.getConfigBoolean("enable.finish.command", false)) {
try {
Expand Down
42 changes: 42 additions & 0 deletions src/main/java/com/rarchives/ripme/utils/Http.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import javax.net.ssl.*;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -230,4 +233,43 @@ public Response response() throws IOException {
}
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());
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/LabelsBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ save.descriptions = Save descriptions
prefer.mp4.over.gif = Prefer MP4 over GIF
restore.window.position = Restore window position
remember.url.history = Remember URL history
ssl.verify.off = SSL verify off
loading.history.from = Loading history from

# Queue keys
Expand Down

0 comments on commit 255e388

Please sign in to comment.