Skip to content
0.2.0-dev Download ZIP
89 lines ·4.5 KB Raw
1<?xml version="1.0" encoding="UTF-8" ?>
2<class name="TLSOptions" inherits="RefCounted" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 TLS configuration for clients and servers.
5 </brief_description>
6 <description>
7 TLSOptions abstracts the configuration options for the [StreamPeerTLS] and [PacketPeerDTLS] classes.
8 Objects of this class cannot be instantiated directly, and one of the static methods [method client], [method client_unsafe], or [method server] should be used instead.
9 [codeblocks]
10 [gdscript]
11 # Create a TLS client configuration which uses our custom trusted CA chain.
12 var client_trusted_cas = load("res://my_trusted_cas.crt")
13 var client_tls_options = TLSOptions.client(client_trusted_cas)
14
15 # Create a TLS server configuration.
16 var server_certs = load("res://my_server_cas.crt")
17 var server_key = load("res://my_server_key.key")
18 var server_tls_options = TLSOptions.server(server_key, server_certs)
19 [/gdscript]
20 [/codeblocks]
21 </description>
22 <tutorials>
23 </tutorials>
24 <methods>
25 <method name="client" qualifiers="static">
26 <return type="TLSOptions" />
27 <param index="0" name="trusted_chain" type="X509Certificate" default="null" />
28 <param index="1" name="common_name_override" type="String" default="&quot;&quot;" />
29 <description>
30 Creates a TLS client configuration which validates certificates and their common names (fully qualified domain names).
31 You can specify a custom [param trusted_chain] of certification authorities (the default CA list will be used if [code]null[/code]), and optionally provide a [param common_name_override] if you expect the certificate to have a common name other than the server FQDN.
32 [b]Note:[/b] On the Web platform, TLS verification is always enforced against the CA list of the web browser. This is considered a security feature.
33 </description>
34 </method>
35 <method name="client_unsafe" qualifiers="static">
36 <return type="TLSOptions" />
37 <param index="0" name="trusted_chain" type="X509Certificate" default="null" />
38 <description>
39 Creates an [b]unsafe[/b] TLS client configuration where certificate validation is optional. You can optionally provide a valid [param trusted_chain], but the common name of the certificates will never be checked. Using this configuration for purposes other than testing [b]is not recommended[/b].
40 [b]Note:[/b] On the Web platform, TLS verification is always enforced against the CA list of the web browser. This is considered a security feature.
41 </description>
42 </method>
43 <method name="get_common_name_override" qualifiers="const">
44 <return type="String" />
45 <description>
46 Returns the common name (domain name) override specified when creating with [method TLSOptions.client].
47 </description>
48 </method>
49 <method name="get_own_certificate" qualifiers="const">
50 <return type="X509Certificate" />
51 <description>
52 Returns the [X509Certificate] specified when creating with [method TLSOptions.server].
53 </description>
54 </method>
55 <method name="get_private_key" qualifiers="const">
56 <return type="CryptoKey" />
57 <description>
58 Returns the [CryptoKey] specified when creating with [method TLSOptions.server].
59 </description>
60 </method>
61 <method name="get_trusted_ca_chain" qualifiers="const">
62 <return type="X509Certificate" />
63 <description>
64 Returns the CA [X509Certificate] chain specified when creating with [method TLSOptions.client] or [method TLSOptions.client_unsafe].
65 </description>
66 </method>
67 <method name="is_server" qualifiers="const">
68 <return type="bool" />
69 <description>
70 Returns [code]true[/code] if created with [method TLSOptions.server], [code]false[/code] otherwise.
71 </description>
72 </method>
73 <method name="is_unsafe_client" qualifiers="const">
74 <return type="bool" />
75 <description>
76 Returns [code]true[/code] if created with [method TLSOptions.client_unsafe], [code]false[/code] otherwise.
77 </description>
78 </method>
79 <method name="server" qualifiers="static">
80 <return type="TLSOptions" />
81 <param index="0" name="key" type="CryptoKey" />
82 <param index="1" name="certificate" type="X509Certificate" />
83 <description>
84 Creates a TLS server configuration using the provided [param key] and [param certificate].
85 [b]Note:[/b] The [param certificate] should include the full certificate chain up to the signing CA (certificates file can be concatenated using a general purpose text editor).
86 </description>
87 </method>
88 </methods>
89</class>