Java API
HSM Dinamo
Loading...
Looking for...
No entries found
SetTlsBundle.java

Example of the key/certificate pair configuration used by the HSM when establishing the TLS tunnel.

See Note on examples.
package doxy.examples;
import com.dinamonetworks.Dinamo;
import br.com.trueaccess.TacException;
import br.com.trueaccess.TacNDJavaLib;
public class SetTlsBundle {
public static void main(String[] args) {
String ip = "127.0.0.1";
String user = "master";
String pwd = "12345678";
// Objetos de chave e certificado já armazenados no HSM.
// Use a notação "<usuário>/<nome-do-objeto>" para objetos em outras partições.
String tlsKeyId = "tls_key";
String tlsCertId = "tls_cert";
Dinamo api = new Dinamo();
try {
api.openSession(ip, user, pwd, TacNDJavaLib.DEFAULT_PORT,
TacNDJavaLib.ENCRYPTED_CONN);
// Define o bundle TLS personalizado.
api.setTlsBundle(tlsKeyId, tlsCertId);
System.out.println("TLS bundle updated successfully.");
// Redefine para a chave/cert TLS padrão de fábrica.
api.setTlsBundle("", "");
System.out.println("TLS bundle reset to default.");
} catch (TacException e) {
e.printStackTrace();
} finally {
try { api.closeSession(); } catch (TacException ignore) {}
}
}
}