Beispiel #1
0
  private boolean validateServerIdentity() {
    PrivateIdentityCertificate privateCert = config.getSecurity().getServerPrivateCertificate();
    PublicIdentityCertificate publicCert = config.getSecurity().getServerPublicCertificate();

    if (privateCert == null || publicCert == null) {
      return false;
    }

    // Validate the signature
    if (!publicCert.verifySelfSigned()) {
      logger.error("Server signature is not self signed! Generating new server identity.");
      return false;
    }

    return true;
  }
Beispiel #2
0
  private void initConfig() {
    if (Files.isRegularFile(Config.getConfigFile())) {
      try {
        config = Config.load(Config.getConfigFile());
      } catch (IOException e) {
        logger.error("Failed to load config", e);
        config = new Config();
      }
    } else {
      config = new Config();
    }
    if (!config.getDefaultModSelection().hasModule(TerasologyConstants.CORE_GAMEPLAY_MODULE)) {
      config.getDefaultModSelection().addModule(TerasologyConstants.CORE_GAMEPLAY_MODULE);
    }

    if (!validateServerIdentity()) {
      CertificateGenerator generator = new CertificateGenerator();
      CertificatePair serverIdentity = generator.generateSelfSigned();
      config
          .getSecurity()
          .setServerCredentials(serverIdentity.getPublicCert(), serverIdentity.getPrivateCert());
      config.save();
    }

    renderingConfig = config.getRendering();
    logger.info("Video Settings: " + renderingConfig.toString());
    CoreRegistry.putPermanently(Config.class, config);
  }