소스 검색

mcMMO now supports SSL and tries to use it by default for MySQL (turn this off in config.yml MySQL.Server.SSL)
this fixes a lot of console spam from default mysql installs

nossr50 6 년 전
부모
커밋
4cfb7a5f4b

+ 2 - 0
Changelog.txt

@@ -15,9 +15,11 @@ Version 2.1.0
  + Added links to mcMMO related websites to various commands
  + Certain elements of mcMMO's UI have been restyled
  + Added the tagline "Overhaul Era" to various locations until 3.0.0 comes out
+ + (MySQL) Added support for SSL for MySQL/MariaDB (Off by default)
  + (Skills) Tool alerts now are sent to the Action Bar
  + (Skills) Super Ability activation alerts are now sent to the Action Bar
  + (Skills) Certain Skill messages are now sent to the Action Bar
+ + (Config) Added option to use SSL for MySQL in config.yml
  + (Config) Added option to disable the new URL links to config.yml
  + (Config) New config file added coreskills.yml
  + (Config) Added rank settings for the new Woodcutting skill

+ 1 - 0
src/main/java/com/gmail/nossr50/config/Config.java

@@ -346,6 +346,7 @@ public class Config extends AutoUpdateConfigLoader {
     public String getMySQLUserPassword() { return getStringIncludingInts("MySQL.Database.User_Password"); }
     public int getMySQLMaxConnections(PoolIdentifier identifier) { return config.getInt("MySQL.Database.MaxConnections." + StringUtils.getCapitalized(identifier.toString()), 30); }
     public int getMySQLMaxPoolSize(PoolIdentifier identifier) { return config.getInt("MySQL.Database.MaxPoolSize." + StringUtils.getCapitalized(identifier.toString()), 10); }
+    public boolean getMySQLSSL() { return config.getBoolean("MySQL.Server.SSL", true); }
 
     private String getStringIncludingInts(String key) {
         String str = config.getString(key);

+ 7 - 0
src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java

@@ -36,6 +36,13 @@ public final class SQLDatabaseManager implements DatabaseManager {
         String connectionString = "jdbc:mysql://" + Config.getInstance().getMySQLServerName()
                 + ":" + Config.getInstance().getMySQLServerPort() + "/" + Config.getInstance().getMySQLDatabaseName();
 
+        if(Config.getInstance().getMySQLSSL())
+            connectionString = "jdbc:mysql://" + Config.getInstance().getMySQLServerName()
+                    + ":" + Config.getInstance().getMySQLServerPort() + "/" + Config.getInstance().getMySQLDatabaseName() +
+                    "?verifyServerCertificate=false"+
+                    "&useSSL=true"+
+                    "&requireSSL=true";
+
         try {
             // Force driver to load if not yet loaded
             Class.forName("com.mysql.jdbc.Driver");

+ 1 - 1
src/main/resources/config.yml

@@ -166,7 +166,7 @@ MySQL:
             Load: 20
             Save: 20
     Server:
-        SSL: false
+        SSL: true
         Port: 3306
         Address: localhost