sgcWebSockets 2022.8.0부터 서버 및 클라이언트 UDP 컴포넌트에서 DTLS over UDP를 지원해요. 이제 TLS 기반의 WebSocket이나 HTTP 프로토콜처럼 UDP를 통해 암호화된 메시지를 보낼 수 있어요.
Wikipedia에서: DTLS(Datagram Transport Layer Security)는 데이터그램 기반 애플리케이션에 보안을 제공하는 통신 프로토콜로, 도청, 변조, 메시지 위조를 방지하도록 설계된 방식으로 통신할 수 있게 해요. DTLS 프로토콜은 스트림 기반의 TLS 프로토콜을 기반으로 하며, 유사한 보안 보장을 제공하도록 설계됐어요.
설정
설정 방법은 다른 컴포넌트와 매우 유사해요. DTLSOptions라는 새 속성에서 파일 인증서, 개인 키, 인증서 검증 등 DTLS 옵션을 설정할 수 있어요. DTLS를 활성화하려면 서버 시작 전 또는 클라이언트에서 서버로 메시지를 보내기 전에 DTLS 속성을 True로 설정하세요.
인증서는 PEM 형식이어야 해요. 다른 형식의 인증서라면 먼저 PEM으로 변환하세요.
DTLS requires openSSL 1.1+ so the default Indy version that comes with Rad Studio currently doesn't support it. Only sgcWebSockets Enterprise version supports DTLS (because this version comes with a custom indy version that supports openSSL 1.1 and 3.0).
서버
// ... server
server := TsgcUDPServer.Create(nil);
server.Port := StrToInt(txtDefaultPort.Text);
server.Bindings.Clear;
With server.Bindings.Add do
begin
IP := '127.0.0.1';
Port := 5430;
end;
// ... dtls
server.DTLS := True;
server.DTLSOptions.CertFile := 'certificate.pem';
server.DTLSOptions.KeyFile := 'privatekey.pem';
// ... active
server.Active := True;
클라이언트
// ... client
client.Host := '127.0.0.1';
client.Port := 5430;
client.DTLS := True;
client.DTLSOptions.CertFile := 'certificate.pem';
client.DTLSOptions.KeyFile := 'privatekey.pem';
client.WriteData('Hello from sgcWebSockets!!!');
데모
Find below a link to a DTLS over UDP demo that shows how it works on windows using the sgcWebSockets library.
