PageRenderTime 22ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSConfig.as

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
ActionScript | 70 lines | 50 code | 8 blank | 12 comment | 6 complexity | e1ae1f100da110731c30ca4e6a322aa2 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. /**
  2. * TLSConfig
  3. *
  4. * A set of configuration parameters for use by a TLSSocket or a TLSEngine.
  5. * Most parameters are optional and will be set to appropriate default values for most use.
  6. *
  7. * Copyright (c) 2007 Henri Torgemane
  8. *
  9. * See LICENSE.txt for full license information.
  10. */
  11. package com.hurlant.crypto.tls {
  12. import flash.utils.ByteArray;
  13. import com.hurlant.util.der.PEM;
  14. import com.hurlant.crypto.rsa.RSAKey;
  15. import com.hurlant.crypto.cert.X509CertificateCollection;
  16. import com.hurlant.crypto.cert.MozillaRootCertificates;
  17. public class TLSConfig {
  18. public var entity:uint; // SERVER | CLIENT
  19. public var certificate:ByteArray;
  20. public var privateKey:RSAKey;
  21. public var cipherSuites:Array;
  22. public var compressions:Array;
  23. public var ignoreCommonNameMismatch:Boolean = false;
  24. public var trustAllCertificates:Boolean = false;
  25. public var trustSelfSignedCertificates:Boolean = false;
  26. public var promptUserForAcceptCert:Boolean = false;
  27. public var CAStore:X509CertificateCollection;
  28. public var localKeyStore:X509CertificateCollection;
  29. public var version:uint;
  30. public function TLSConfig( entity:uint, cipherSuites:Array = null, compressions:Array = null,
  31. certificate:ByteArray = null, privateKey:RSAKey = null, CAStore:X509CertificateCollection = null, ver:uint = 0x00) {
  32. this.entity = entity;
  33. this.cipherSuites = cipherSuites;
  34. this.compressions = compressions;
  35. this.certificate = certificate;
  36. this.privateKey = privateKey;
  37. this.CAStore = CAStore;
  38. this.version = ver;
  39. // default settings.
  40. if (cipherSuites==null) {
  41. this.cipherSuites = CipherSuites.getDefaultSuites();
  42. }
  43. if (compressions==null) {
  44. this.compressions = [TLSSecurityParameters.COMPRESSION_NULL];
  45. }
  46. if (CAStore==null) {
  47. this.CAStore = new MozillaRootCertificates;
  48. }
  49. if (ver==0x00) {
  50. // Default to TLS
  51. this.version = TLSSecurityParameters.PROTOCOL_VERSION;
  52. }
  53. }
  54. public function setPEMCertificate(cert:String, key:String = null):void {
  55. if (key == null) {
  56. key = cert; // for folks who like to concat those two in one file.
  57. }
  58. certificate = PEM.readCertIntoArray(cert);
  59. privateKey = PEM.readRSAPrivateKey(key);
  60. }
  61. }
  62. }