Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Windows cert store. #106

Merged
merged 3 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/main/java/net/fabricmc/installer/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import net.fabricmc.installer.util.ArgumentParser;
import net.fabricmc.installer.util.CrashDialog;
import net.fabricmc.installer.util.MetaHandler;
import net.fabricmc.installer.util.OperatingSystem;
import net.fabricmc.installer.util.Reference;

public class Main {
Expand All @@ -35,6 +36,11 @@ public class Main {
public static final List<Handler> HANDLERS = new ArrayList<>();

public static void main(String[] args) throws IOException {
if (OperatingSystem.CURRENT == OperatingSystem.WINDOWS) {
// Use the operating system cert store
System.setProperty("javax.net.ssl.trustStoreType", "WINDOWS-ROOT");
}

System.out.println("Loading Fabric Installer: " + Main.class.getPackage().getImplementationVersion());

HANDLERS.add(new ClientHandler());
Expand Down
16 changes: 3 additions & 13 deletions src/main/java/net/fabricmc/installer/launcher/NativesHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
import java.util.Map;
import java.util.Objects;

import net.fabricmc.installer.util.OperatingSystem;

public class NativesHelper {
private static final String OS_ID = getOS() + "-" + System.getProperty("os.arch").toLowerCase(Locale.ROOT);
private static final String OS_ID = OperatingSystem.CURRENT.name().toLowerCase(Locale.ROOT) + "-" + System.getProperty("os.arch").toLowerCase(Locale.ROOT);
private static final Map<String, String> NATIVES_MAP = getNativesMap();

private static boolean loaded = false;
Expand All @@ -49,18 +51,6 @@ private static Map<String, String> getNativesMap() {
return natives;
}

private static String getOS() {
String osName = System.getProperty("os.name").toLowerCase(Locale.ROOT);

if (osName.contains("win")) {
return "windows";
} else if (osName.contains("mac")) {
return "macos";
} else {
return "linux";
}
}

public static boolean loadSafelyIfCompatible() {
if (isCompatible()) {
try {
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/net/fabricmc/installer/util/OperatingSystem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.fabricmc.installer.util;

import java.util.Locale;

public enum OperatingSystem {
WINDOWS,
MACOS,
LINUX;

public static final OperatingSystem CURRENT = getCurrent();

private static OperatingSystem getCurrent() {
String osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);

if (osName.contains("win")) {
return WINDOWS;
} else if (osName.contains("mac")) {
return MACOS;
} else {
return LINUX;
}
}
}
5 changes: 2 additions & 3 deletions src/main/java/net/fabricmc/installer/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,15 @@ public ResourceBundle newBundle(String baseName, Locale locale, String format, C
});

public static Path findDefaultInstallDir() {
String os = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
Path dir;

if (os.contains("win") && System.getenv("APPDATA") != null) {
if (OperatingSystem.CURRENT == OperatingSystem.WINDOWS && System.getenv("APPDATA") != null) {
dir = Paths.get(System.getenv("APPDATA")).resolve(".minecraft");
} else {
String home = System.getProperty("user.home", ".");
Path homeDir = Paths.get(home);

if (os.contains("mac")) {
if (OperatingSystem.CURRENT == OperatingSystem.MACOS) {
dir = homeDir.resolve("Library").resolve("Application Support").resolve("minecraft");
} else {
dir = homeDir.resolve(".minecraft");
Expand Down