class_tlsoptions.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/TLSOptions.xml.
  6. .. _class_TLSOptions:
  7. TLSOptions
  8. ==========
  9. **Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. TLS configuration for clients and servers.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. TLSOptions abstracts the configuration options for the :ref:`StreamPeerTLS<class_StreamPeerTLS>` and :ref:`PacketPeerDTLS<class_PacketPeerDTLS>` classes.
  15. Objects of this class cannot be instantiated directly, and one of the static methods :ref:`client<class_TLSOptions_method_client>`, :ref:`client_unsafe<class_TLSOptions_method_client_unsafe>`, or :ref:`server<class_TLSOptions_method_server>` should be used instead.
  16. .. tabs::
  17. .. code-tab:: gdscript
  18. # Create a TLS client configuration which uses our custom trusted CA chain.
  19. var client_trusted_cas = load("res://my_trusted_cas.crt")
  20. var client_tls_options = TLSOptions.client(client_trusted_cas)
  21. # Create a TLS server configuration.
  22. var server_certs = load("res://my_server_cas.crt")
  23. var server_key = load("res://my_server_key.key")
  24. var server_tls_options = TLSOptions.server(server_key, server_certs)
  25. .. rst-class:: classref-reftable-group
  26. Methods
  27. -------
  28. .. table::
  29. :widths: auto
  30. +-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`TLSOptions<class_TLSOptions>` | :ref:`client<class_TLSOptions_method_client>`\ (\ trusted_chain\: :ref:`X509Certificate<class_X509Certificate>` = null, common_name_override\: :ref:`String<class_String>` = ""\ ) |static| |
  32. +-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`TLSOptions<class_TLSOptions>` | :ref:`client_unsafe<class_TLSOptions_method_client_unsafe>`\ (\ trusted_chain\: :ref:`X509Certificate<class_X509Certificate>` = null\ ) |static| |
  34. +-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`String<class_String>` | :ref:`get_common_name_override<class_TLSOptions_method_get_common_name_override>`\ (\ ) |const| |
  36. +-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`X509Certificate<class_X509Certificate>` | :ref:`get_own_certificate<class_TLSOptions_method_get_own_certificate>`\ (\ ) |const| |
  38. +-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`CryptoKey<class_CryptoKey>` | :ref:`get_private_key<class_TLSOptions_method_get_private_key>`\ (\ ) |const| |
  40. +-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`X509Certificate<class_X509Certificate>` | :ref:`get_trusted_ca_chain<class_TLSOptions_method_get_trusted_ca_chain>`\ (\ ) |const| |
  42. +-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`bool<class_bool>` | :ref:`is_server<class_TLSOptions_method_is_server>`\ (\ ) |const| |
  44. +-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`bool<class_bool>` | :ref:`is_unsafe_client<class_TLSOptions_method_is_unsafe_client>`\ (\ ) |const| |
  46. +-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`TLSOptions<class_TLSOptions>` | :ref:`server<class_TLSOptions_method_server>`\ (\ key\: :ref:`CryptoKey<class_CryptoKey>`, certificate\: :ref:`X509Certificate<class_X509Certificate>`\ ) |static| |
  48. +-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. .. rst-class:: classref-section-separator
  50. ----
  51. .. rst-class:: classref-descriptions-group
  52. Method Descriptions
  53. -------------------
  54. .. _class_TLSOptions_method_client:
  55. .. rst-class:: classref-method
  56. :ref:`TLSOptions<class_TLSOptions>` **client**\ (\ trusted_chain\: :ref:`X509Certificate<class_X509Certificate>` = null, common_name_override\: :ref:`String<class_String>` = ""\ ) |static| :ref:`🔗<class_TLSOptions_method_client>`
  57. Creates a TLS client configuration which validates certificates and their common names (fully qualified domain names).
  58. You can specify a custom ``trusted_chain`` of certification authorities (the default CA list will be used if ``null``), and optionally provide a ``common_name_override`` if you expect the certificate to have a common name other than the server FQDN.
  59. \ **Note:** On the Web platform, TLS verification is always enforced against the CA list of the web browser. This is considered a security feature.
  60. .. rst-class:: classref-item-separator
  61. ----
  62. .. _class_TLSOptions_method_client_unsafe:
  63. .. rst-class:: classref-method
  64. :ref:`TLSOptions<class_TLSOptions>` **client_unsafe**\ (\ trusted_chain\: :ref:`X509Certificate<class_X509Certificate>` = null\ ) |static| :ref:`🔗<class_TLSOptions_method_client_unsafe>`
  65. Creates an **unsafe** TLS client configuration where certificate validation is optional. You can optionally provide a valid ``trusted_chain``, but the common name of the certificates will never be checked. Using this configuration for purposes other than testing **is not recommended**.
  66. \ **Note:** On the Web platform, TLS verification is always enforced against the CA list of the web browser. This is considered a security feature.
  67. .. rst-class:: classref-item-separator
  68. ----
  69. .. _class_TLSOptions_method_get_common_name_override:
  70. .. rst-class:: classref-method
  71. :ref:`String<class_String>` **get_common_name_override**\ (\ ) |const| :ref:`🔗<class_TLSOptions_method_get_common_name_override>`
  72. Returns the common name (domain name) override specified when creating with :ref:`client<class_TLSOptions_method_client>`.
  73. .. rst-class:: classref-item-separator
  74. ----
  75. .. _class_TLSOptions_method_get_own_certificate:
  76. .. rst-class:: classref-method
  77. :ref:`X509Certificate<class_X509Certificate>` **get_own_certificate**\ (\ ) |const| :ref:`🔗<class_TLSOptions_method_get_own_certificate>`
  78. Returns the :ref:`X509Certificate<class_X509Certificate>` specified when creating with :ref:`server<class_TLSOptions_method_server>`.
  79. .. rst-class:: classref-item-separator
  80. ----
  81. .. _class_TLSOptions_method_get_private_key:
  82. .. rst-class:: classref-method
  83. :ref:`CryptoKey<class_CryptoKey>` **get_private_key**\ (\ ) |const| :ref:`🔗<class_TLSOptions_method_get_private_key>`
  84. Returns the :ref:`CryptoKey<class_CryptoKey>` specified when creating with :ref:`server<class_TLSOptions_method_server>`.
  85. .. rst-class:: classref-item-separator
  86. ----
  87. .. _class_TLSOptions_method_get_trusted_ca_chain:
  88. .. rst-class:: classref-method
  89. :ref:`X509Certificate<class_X509Certificate>` **get_trusted_ca_chain**\ (\ ) |const| :ref:`🔗<class_TLSOptions_method_get_trusted_ca_chain>`
  90. Returns the CA :ref:`X509Certificate<class_X509Certificate>` chain specified when creating with :ref:`client<class_TLSOptions_method_client>` or :ref:`client_unsafe<class_TLSOptions_method_client_unsafe>`.
  91. .. rst-class:: classref-item-separator
  92. ----
  93. .. _class_TLSOptions_method_is_server:
  94. .. rst-class:: classref-method
  95. :ref:`bool<class_bool>` **is_server**\ (\ ) |const| :ref:`🔗<class_TLSOptions_method_is_server>`
  96. Returns ``true`` if created with :ref:`server<class_TLSOptions_method_server>`, ``false`` otherwise.
  97. .. rst-class:: classref-item-separator
  98. ----
  99. .. _class_TLSOptions_method_is_unsafe_client:
  100. .. rst-class:: classref-method
  101. :ref:`bool<class_bool>` **is_unsafe_client**\ (\ ) |const| :ref:`🔗<class_TLSOptions_method_is_unsafe_client>`
  102. Returns ``true`` if created with :ref:`client_unsafe<class_TLSOptions_method_client_unsafe>`, ``false`` otherwise.
  103. .. rst-class:: classref-item-separator
  104. ----
  105. .. _class_TLSOptions_method_server:
  106. .. rst-class:: classref-method
  107. :ref:`TLSOptions<class_TLSOptions>` **server**\ (\ key\: :ref:`CryptoKey<class_CryptoKey>`, certificate\: :ref:`X509Certificate<class_X509Certificate>`\ ) |static| :ref:`🔗<class_TLSOptions_method_server>`
  108. Creates a TLS server configuration using the provided ``key`` and ``certificate``.
  109. \ **Note:** The ``certificate`` should include the full certificate chain up to the signing CA (certificates file can be concatenated using a general purpose text editor).
  110. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  111. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  112. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  113. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  114. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  115. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  116. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  117. .. |void| replace:: :abbr:`void (No return value.)`