Junior — Middle
Have you used the TLS protocol in your last project?
sobes.tech AI
Answer from AI
TLS (Transport Layer Security) is a protocol that provides a secure encrypted connection between a client and a server. In Java, standard libraries such as javax.net.ssl are typically used for working with TLS.
In projects, TLS is used to protect data transmission, for example, in HTTPS connections or when exchanging messages through secure sockets.
An example of using TLS in Java is creating an SSL socket:
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.SSLSocket;
public class TLSExample {
public static void main(String[] args) throws Exception {
SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
try (SSLSocket socket = (SSLSocket) factory.createSocket("example.com", 443)) {
socket.startHandshake();
// Now the connection is secured with TLS
}
}
}
In real projects, TLS is configured through server and client configurations, ensuring certificate validation, encryption, and data integrity.