Histórico de mensagens sobre ssl

EXIBINDO CONVERSAS RECENTES:

Texto: ssl
Data: 16/10/2024
# pix
Avatar discord do usuario emiliocalvet

emiliocalvet

Ver Respostas

System.setProperty("javax.net.ssl.keyStore", credentials.getCertificate());

O certificado que coloquei foi de forma global, pra ir em todas as requisições independente de qual seja. Não sei se era conflito ou coisa do tipo mas essa implementação que mandei parou de dar erro quando removi o SDK. Pelo menos até agr.

# pix
Avatar discord do usuario emiliocalvet

emiliocalvet

java
@Getter
public class Credentials {
private final String clientId;
private final String clientSecret;
private final String certificate;
private final boolean sandbox;
private final boolean debug;

public Credentials() {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
InputStream credentialsFile = classLoader.getResourceAsStream("credentials.json");
assert credentialsFile != null;
JSONTokener tokenizer = new JSONTokener(credentialsFile);
JSONObject credentials = new JSONObject(tokenizer);
try {
credentialsFile.close();
} catch (IOException e) {
System.out.println("Impossible to close file credentials.json");
}

this.clientId = credentials.getString("client_id");
this.clientSecret = credentials.getString("client_secret");
this.certificate = credentials.getString("certificate");
this.sandbox = credentials.getBoolean("sandbox");
this.debug = credentials.getBoolean("debug");
}

public HashMap getOptionsMap() {
HashMap options = new HashMap<>();
options.put("client_id", this.getClientId());
options.put("client_secret", this.getClientSecret());
options.put("certificate", this.getCertificate());
options.put("sandbox", this.isSandbox());
return options;
}

public JSONObject getOptionsJson() {
return new JSONObject(this.getOptionsMap());
}
}