Socket.hx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (C)2005-2019 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. package sys.ssl;
  23. /**
  24. A TLS socket class : allow you to both connect to a given server and exchange messages or start your own server and wait for connections.
  25. **/
  26. extern class Socket extends sys.net.Socket {
  27. static var DEFAULT_VERIFY_CERT:Null<Bool>;
  28. static var DEFAULT_CA:Null<sys.ssl.Certificate>;
  29. /**
  30. Define if peer certificate is verified during SSL handshake.
  31. **/
  32. var verifyCert:Null<Bool>;
  33. function new():Void;
  34. /**
  35. Perform the SSL handshake.
  36. **/
  37. function handshake():Void;
  38. /**
  39. Configure the certificate chain for peer certificate verification.
  40. **/
  41. function setCA(cert:sys.ssl.Certificate):Void;
  42. /**
  43. Configure the hostname for Server Name Indication TLS extension.
  44. **/
  45. function setHostname(name:String):Void;
  46. /**
  47. Configure own certificate and private key.
  48. **/
  49. function setCertificate(cert:Certificate, key:Key):Void;
  50. /**
  51. Configure additionals certificates and private keys for Server Name Indication extension.
  52. The callback may be called during handshake to determine the certificate to use.
  53. **/
  54. function addSNICertificate(cbServernameMatch:String->Bool, cert:Certificate, key:Key):Void;
  55. /**
  56. Return the certificate received from the other side of a connection.
  57. **/
  58. function peerCertificate():sys.ssl.Certificate;
  59. }