Add optional useSSL config option

This commit is contained in:
games647
2017-02-23 09:16:11 +01:00
parent f37cc0a0db
commit 863607c9a4
4 changed files with 12 additions and 5 deletions

View File

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2015
Copyright (c) 2015-17
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -23,7 +23,7 @@ public class AuthStorage {
private final HikariDataSource dataSource;
public AuthStorage(FastLoginCore<?, ?, ?> core, String driver, String host, int port, String databasePath
, String user, String pass) {
, String user, String pass, boolean useSSL) {
this.core = core;
HikariConfig databaseConfig = new HikariConfig();
@ -34,6 +34,7 @@ public class AuthStorage {
//a try to fix https://www.spigotmc.org/threads/fastlogin.101192/page-26#post-1874647
Properties properties = new Properties();
properties.setProperty("date_string_format", "yyyy-MM-dd HH:mm:ss");
properties.setProperty("useSSL", String.valueOf(useSSL));
databaseConfig.setDataSourceProperties(properties);
ThreadFactoryBuilder threadFactoryBuilder = new ThreadFactoryBuilder()

View File

@ -162,7 +162,9 @@ public class FastLoginCore<P extends C, C, T extends PlatformPlugin<C>> {
String user = sharedConfig.get("username", "");
String password = sharedConfig.get("password", "");
storage = new AuthStorage(this, driver, host, port, database, user, password);
boolean useSSL = sharedConfig.get("useSSL", false);
storage = new AuthStorage(this, driver, host, port, database, user, password, useSSL);
try {
storage.createTables();
return true;

View File

@ -164,10 +164,14 @@ driver: org.sqlite.JDBC
# File location
database: '{pluginDir}/FastLogin.db'
# MySQL
# MySQL/MariaDB
#driver: com.mysql.jdbc.Driver
#host: localhost
#port: 3306
#database: fastlogin
#username: myUser
#password: myPassword
#password: myPassword
# It's strongly recommended to enable SSL and setup a SSL certificate if the MySQL server isn't running on the same
# machine
#useSSL: false