Skip to content

Latest commit

 

History

History
38 lines (23 loc) · 2.56 KB

File metadata and controls

38 lines (23 loc) · 2.56 KB

HelloNetcode Secure Connection sample

The NetCode package provides a way to create client and server worlds and securely connect them together (client connects to server) by using a custom bootstrapper.

See

Requirements

Only needs the bootstrap to set-up client and server world.

  • BootstrapAndFrontend

Sample description

This sample shows the modification needed to the bootstrap functionality to enable the secure connection feature.

This sample contains no scene as nothing needs to be added to the scene to enable this feature.

To set up a secure connection on the network driver a custom/manual driver needs to be set up so different network parameters can be passed to it. The custom driver constructor needs to be set up in the bootstrap to be there early enough to replace the default driver. This is done in SecureBootStrapExtension.cs but it's disabled with the ENABLE_NETCODE_SAMPLE_SECURE define at the top of the file, since enabling it means it's enforced globally through the whole project. To enable it just uncomment the define.

Generating secure parameters

Inside NetworkParams.cs you will see static variables containing this sample's generated certificate. For your own game you would generate these by yourself. Follow the link '[Generate Required Keys and Certificate]' above to see how to do this.

NOTE: Make sure that you do not ship your generated keys and certificates when publishing your game. It is very easy for a malicious user to decompile the source code even if obfuscated and see the keys.

Passing secure parameters

The generated certificates are passed to the network driver in HelloNetcode_SecureDriverConstructor.cs. This is using a helper function to set up default values on the network settings. You can change this to manually construct the network driver instance, or pass in your own network settings using the appropriate override.