private void generateSelfSignedCertificate(File certFile, File passFile)
			throws IOException, GeneralSecurityException {

		String alias = "bsimroot";
		char[] password = "unusedpassword".toCharArray();

		PasswordProtection pp = new PasswordProtection(password);
		try {
			// TODO: should subjectAlternativeNames be supported?
			KeyStore keyStore = ApplicationKeyManagerUtils.createKeyStore(alias, "CN=BSimServer",
				365 * 2, null, null, "JKS", null, password);

			ApplicationKeyManagerUtils.exportX509Certificates(keyStore.getCertificateChain(alias),
				certFile);
			Key key = keyStore.getKey(alias, password);

			try (FileOutputStream fout = new FileOutputStream(passFile);
					PrintWriter writer = new PrintWriter(fout)) {
				writer.print("-----BEGIN PRIVATE KEY-----");
				writer.println();
				String base64 = Base64.getEncoder().encodeToString(key.getEncoded());
				while (base64.length() != 0) {
					int endIndex = Math.min(44, base64.length());
					String line = base64.substring(0, endIndex);
					writer.println(line);
					base64 = base64.substring(endIndex);
				}
				writer.println("-----END PRIVATE KEY-----");
				writer.println();
			}

			passFile.setExecutable(false, false);		// Clear execute permission for everybody
			passFile.setReadable(false, false);			// Clear read permission for everybody
			passFile.setWritable(false, false);			// Clear write permission for everybody
			passFile.setReadable(true, true);			// Let owner read the file
		}
		catch (NoSuchAlgorithmException | UnrecoverableEntryException e) {
			throw new KeyStoreException("Failed to generate BSim server certificate", e);
		}
		finally {
			Arrays.fill(password, ' ');
			try {
				pp.destroy();
			}
			catch (DestroyFailedException e) {
				throw new AssertException(e); // unexpected for simple password clearing
			}
		}
	}
Servers that allow SSL connections are required to have a certificate that allows it to
authenticate itself to users.  The BSim server does not authenticate itself to clients, but
a certificate must still be present.  We generate a self-signed certificate.
@param certFile will hold the public portion of the generated certificate
@param passFile will hold the private portion
@throws IOException if the password file cannot be opened for writing
@throws GeneralSecurityException if the keystore cannot be created
Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java