기술 자료

지원

Relay

Relay

DTLS 암호화 활성화

Configure your Relay client to use Datagram Transport Layer Security for encrypted connections.
읽는 시간 1분최근 업데이트: 3달 전

참고
참고: DTLS 암호화를 활성화하면 메시지의 암호화만 활성화하며, 시간 초과 등의 다른 Relay 동작은 그대로 유지됩니다.
Relay는 Relay 서버와 주고받는 모든 UDP 커뮤니케이션에 DTLS 암호화를 지원합니다. 호스트 플레이어로 할당을 생성할 때 Relay 서버의
connectionType
dtls
로 설정하여 DTLS 암호화를 활성화할 수 있습니다.
경고
경고: DTLS를 사용한 보안 연결은 Unity 에디터 버전 2020.3(2020.3.34부터), 2022.1 이상에서만 사용할 수 있습니다.
참고
참고: 호스트 플레이어에 참여하는 플레이어는 호스트 플레이어와 다른 연결 유형을 사용할 수 있습니다. 그러나 대부분의 게임 플랫폼은 암호화된 연결을 요구합니다.
다음 코드 스니핏은
AllocateRelayServerAndGetJoinCode
함수를 사용한 것으로, Relay SDK를 사용하여 할당을 생성하고, 참여 코드를 요청하고, 연결 유형을 DTLS로 설정하는 방법을 보여 줍니다.
public static async Task<(string ipv4address, ushort port, byte[] allocationIdBytes, byte[] connectionData, byte[] key, string joinCode)> AllocateRelayServerAndGetJoinCode(int maxConnections, string region = null){ Allocation allocation; string createJoinCode; try { allocation = await RelayService.Instance.CreateAllocationAsync(maxConnections, region); } catch (Exception e) { Debug.LogError($"Relay create allocation request failed {e.Message}"); throw; } Debug.Log($"server connection data: {allocation.ConnectionData[0]} {allocation.ConnectionData[1]}"); Debug.Log($"server allocation ID: {allocation.AllocationId}"); try { createJoinCode = await RelayService.Instance.GetJoinCodeAsync(allocation.AllocationId); } catch { Debug.LogError("Relay create join code request failed"); throw; } var dtlsEndpoint = allocation.ServerEndpoints.First(e => e.ConnectionType == "dtls"); return (dtlsEndpoint.Host, (ushort)dtlsEndpoint.Port, allocation.AllocationIdBytes, allocation.ConnectionData, allocation.Key, createJoinCode);}