Adobe® AIR® API Reference for HTML Developers
Home  |  Show Classes List |  Index  |  Appendixes

Language Reference only       
SecureSocket 
3D:
Context3D
Context3DBlendFactor
Context3DClearMask
Context3DCompareMode
Context3DProgramType
Context3DRenderMode
Context3DStencilAction
Context3DTextureFormat
Context3DTriangleFace
Context3DVertexBufferFormat
CubeTexture
IndexBuffer3D
Program3D
Stage3D
Texture
VertexBuffer3D
Air.net:
ServiceMonitor
SocketMonitor
URLMonitor
Air.update:
ApplicationUpdater
ApplicationUpdaterUI
DownloadErrorEvent
StatusFileUpdateErrorEvent
StatusFileUpdateEvent
StatusUpdateErrorEvent
StatusUpdateEvent
UpdateEvent
Data:
EncryptedLocalStore
SQLCollationType
SQLColumnNameStyle
SQLColumnSchema
SQLConnection
SQLError
SQLErrorEvent
SQLErrorOperation
SQLEvent
SQLIndexSchema
SQLMode
SQLResult
SQLSchema
SQLSchemaResult
SQLStatement
SQLTableSchema
SQLTransactionLockType
SQLTriggerSchema
SQLUpdateEvent
SQLViewSchema
Desktop:
Clipboard
ClipboardFormats
ClipboardTransferMode
DockIcon
Icon
InteractiveIcon
NativeApplication
NativeProcess
NativeProcessStartupInfo
NotificationType
SystemTrayIcon
Display:
BitmapData
NativeMenu
NativeMenuItem
Screen
Stage
StageDisplayState
StageQuality
Events:
ActivityEvent
AsyncErrorEvent
BrowserInvokeEvent
DataEvent
DatagramSocketDataEvent
DNSResolverEvent
DRMAuthenticateEvent
DRMStatusEvent
ErrorEvent
Event
EventDispatcher
FileListEvent
HTTPStatusEvent
InvokeEvent
InvokeEventReason
IOErrorEvent
LocationChangeEvent
MouseEvent
NativeProcessExitEvent
NetDataEvent
NetMonitorEvent
NetStatusEvent
OutputProgressEvent
ProgressEvent
SampleDataEvent
SecurityErrorEvent
ServerSocketConnectEvent
StatusEvent
StorageVolumeChangeEvent
TimerEvent
UncaughtErrorEvent
UncaughtErrorEvents
File:
File
FileMode
FileStream
StorageVolume
StorageVolumeInfo
Functions:
trace()
generateRandomBytes()
navigateToURL()
sendToURL()
Geom:
Matrix
Point
Rectangle
Media:
AudioDecoder
AudioPlaybackMode
H264Level
H264Profile
H264VideoStreamSettings
ID3Info
InputMediaStream
Microphone
MicrophoneEnhancedMode
MicrophoneEnhancedOptions
Sound
SoundChannel
SoundCodec
SoundLoaderContext
SoundMixer
SoundTransform
VideoCodec
VideoStatus
VideoStreamSettings
Native window:
NativeWindow
NativeWindowBoundsEvent
NativeWindowDisplayState
NativeWindowDisplayStateEvent
NativeWindowInitOptions
NativeWindowRenderMode
NativeWindowResize
NativeWindowSystemChrome
NativeWindowType
Net:
AAAARecord
ARecord
CertificateStatus
DatagramSocket
DNSResolver
FileFilter
InterfaceAddress
IPVersion
LocalConnection
MXRecord
NetConnection
NetMonitor
NetStreamAppendBytesAction
NetStreamMulticastInfo
NetworkInfo
NetworkInterface
ObjectEncoding
PTRRecord
ResourceRecord
Responder
SecureSocket
ServerSocket
SharedObject
SharedObjectFlushStatus
Socket
SRVRecord
URLLoader
URLLoaderDataFormat
URLRequest
URLRequestDefaults
URLRequestHeader
URLRequestMethod
URLStream
URLVariables
XMLSocket
Security:
ReferencesValidationSetting
RevocationCheckSettings
SignatureStatus
SignerTrustSettings
X500DistinguishedName
X509Certificate
XMLSignatureValidator
System:
Capabilities
Security
System
Updater
Ui:
Keyboard
KeyboardType
KeyLocation
Mouse
MouseCursorData
Utils:
Vector
ByteArray
Collator
CollatorMode
CompressionAlgorithm
CurrencyFormatter
CurrencyParseResult
DateTimeFormatter
DateTimeNameContext
DateTimeNameStyle
DateTimeStyle
Endian
HTMLLoader
HTMLPDFCapability
LastOperationStatus
LocaleID
NationalDigitsType
NumberFormatter
NumberParseResult
StringTools
Timer
window.runtime propertywindow.runtime.flash.net.SecureSocket
InheritanceSecureSocket Inheritance Socket Inheritance EventDispatcher Inheritance Object

Runtime Versions:  2

The SecureSocket class enables code to make socket connections using the Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols.

The SSL/TLS protocols provide a mechanism to handle both aspects of a secure socket connection:

  1. Encryption of data communication over the socket
  2. Authentication of the host's identity via its certificate

The supported encryption protocols are SSL 3.0 and higher, and TLS 1.0 and higher. (TLS is the successor protocol for SSL. TLS 1.0 equals SSL 3.1, TLS 1.1 equals SSL 3.2, and so on.) SSL versions lower than 3.0 are not supported.

Validation of the server certificate is performed using the trust store and certificate validation support of the client platform. In addition you can add your own certificates programmatically with the addBinaryChainBuildingCertificate() method.

The SecureSocket class only connects to servers with valid, trusted certificates. You cannot choose to connect to a server in spite of a problem with its certificate. For example, there is no way to connect to a server with an expired certificate. The same is true for a certificate that doesn't chain to a trusted anchor certificate. The connection will not be made, even though the certificate would be valid otherwise.

The SecureSocket class is useful for performing encrypted communication to a trusted server. In other respects, a SecureSocket object behaves like a regular Socket object.

To use the SecureSocket class, create a SecureSocket object (new SecureSocket()). Next, set up your listeners, and then run SecureSocket.connect(host, port). When you successfully connect to the server, the socket dispatches a connect event. A successful connection is one in which the server's security protocols are supported and its certificate is valid and trusted. If the certificate cannot be validated, the Socket dispatches an IOError event.

Important: The Online Certificate Status Protocol (OCSP) is not supported by all operating systems. Users can also disable OCSP checking on individual computers. If OCSP is not supported or is disabled and a certificate does not contain the information necessary to check revocation using a Certificate Revocation List (CRL), then certificate revocation is not checked. The certificate is accepted if otherwise valid. This scenario could allow a server to use a revoked certificate.

See also



Properties
 PropertyDefined By
 InheritedbytesAvailable : uint
[read-only] The number of bytes of data available for reading in the input buffer.
Socket
 InheritedbytesPending : uint
[read-only] Indicates the amount of data (in bytes) awaiting transfer from the socket's write buffer to the network transport layer.
Socket
 Inheritedconnected : Boolean
[read-only] Indicates whether this Socket object is currently connected.
Socket
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
 Inheritedendian : String
Indicates the byte order for the data.
Socket
  isSupported : Boolean
[static] [read-only] Indicates whether secure sockets are supported on the current system.
SecureSocket
 InheritedlocalAddress : String
[read-only] The IP address this socket is bound to on the local machine.
Socket
 InheritedlocalPort : int
[read-only] The port this socket is bound to on the local machine.
Socket
 InheritedobjectEncoding : uint
Controls the version of AMF used when writing or reading an object.
Socket
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
 InheritedremoteAddress : String
[read-only] The IP address of the remote machine to which this socket is connected.
Socket
 InheritedremotePort : int
[read-only] The port on the remote machine to which this socket is connected.
Socket
  serverCertificate : X509Certificate
[read-only] Holds the X.509 certificate obtained from the server after a secure SSL/TLS connection is established.
SecureSocket
  serverCertificateStatus : String
[read-only] Returns the status of the server's certificate.
SecureSocket
 Inheritedtimeout : uint
Indicates the number of milliseconds to wait for a connection.
Socket
Public Methods
 MethodDefined By
  
Creates a new SecureSocket object.
SecureSocket
  
addBinaryChainBuildingCertificate(certificate:ByteArray, trusted:Boolean):void
Adds an X.509 certificate to the local certificate chain that your system uses for validating the server certificate.
SecureSocket
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
EventDispatcher
 Inherited
close():void
Closes the socket.
Socket
  
connect(host:String, port:int):void
[override] Connects the socket to the specified host and port using SSL or TLS.
SecureSocket
 Inherited
dispatchEvent(event:Event):Boolean
Dispatches an event into the event flow.
EventDispatcher
 Inherited
flush():void
Flushes any accumulated data in the socket's output buffer.
Socket
 Inherited
hasEventListener(type:String):Boolean
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
EventDispatcher
 Inherited
hasOwnProperty(name:String):Boolean
Indicates whether an object has a specified property defined.
Object
 Inherited
isPrototypeOf(theClass:Object):Boolean
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
propertyIsEnumerable(name:String):Boolean
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
readBoolean():Boolean
Reads a Boolean value from the socket.
Socket
 Inherited
readByte():int
Reads a signed byte from the socket.
Socket
 Inherited
readBytes(bytes:ByteArray, offset:uint = 0, length:uint = 0):void
Reads the number of data bytes specified by the length parameter from the socket.
Socket
 Inherited
readDouble():Number
Reads an IEEE 754 double-precision floating-point number from the socket.
Socket
 Inherited
readFloat():Number
Reads an IEEE 754 single-precision floating-point number from the socket.
Socket
 Inherited
readInt():int
Reads a signed 32 bit integer from the socket.
Socket
 Inherited
readMultiByte(length:uint, charSet:String):String
Reads a multibyte string from the byte stream, using the specified character set.
Socket
 Inherited
Reads an object from the socket, encoded in AMF serialized format.
Socket
 Inherited
readShort():int
Reads a signed 16 bit integer from the socket.
Socket
 Inherited
Reads an unsigned byte from the socket.
Socket
 Inherited
Reads an unsigned 32 bit integer from the socket.
Socket
 Inherited
Reads an unsigned 16 bit integer from the socket.
Socket
 Inherited
readUTF():String
Reads a UTF-8 string from the socket.
Socket
 Inherited
readUTFBytes(length:uint):String
Reads the number of UTF-8 data bytes specified by the length parameter from the socket, and returns a string.
Socket
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
EventDispatcher
 Inherited
setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
toLocaleString():String
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
toString():String
Returns the string representation of the specified object.
Object
 Inherited
valueOf():Object
Returns the primitive value of the specified object.
Object
 Inherited
willTrigger(type:String):Boolean
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
EventDispatcher
 Inherited
writeBoolean(value:Boolean):void
Writes a Boolean value to the socket.
Socket
 Inherited
writeByte(value:int):void
Writes a byte to the socket.
Socket
 Inherited
writeBytes(bytes:ByteArray, offset:uint = 0, length:uint = 0):void
Writes a sequence of bytes from the specified byte array.
Socket
 Inherited
writeDouble(value:Number):void
Writes an IEEE 754 double-precision floating-point number to the socket.
Socket
 Inherited
writeFloat(value:Number):void
Writes an IEEE 754 single-precision floating-point number to the socket.
Socket
 Inherited
writeInt(value:int):void
Writes a 32 bit signed integer to the socket.
Socket
 Inherited
writeMultiByte(value:String, charSet:String):void
Writes a multibyte string from the byte stream, using the specified character set.
Socket
 Inherited
writeObject(object:*):void
Writes an object to the socket in AMF serialized format.
Socket
 Inherited
writeShort(value:int):void
Writes a 16 bit integer to the socket.
Socket
 Inherited
writeUnsignedInt(value:uint):void
Writes a 32 bit unsigned integer to the socket.
Socket
 Inherited
writeUTF(value:String):void
Writes the following data to the socket: A 16 bit unsigned integer.
Socket
 Inherited
writeUTFBytes(value:String):void
Writes a UTF-8 string to the socket.
Socket
Events
 Event Summary Defined By
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application gains operating system focus and becomes active.EventDispatcher
  Dispatched when the server closes the socket connection.SecureSocket
  Dispatched when a network connection has been established.SecureSocket
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive.EventDispatcher
  Dispatched when an input or output error occurs that causes a send or receive operation to fail.SecureSocket
 InheritedDispatched when a socket moves data from its write buffer to the networking transport layer.Socket
  Dispatched when a call to SecureSocket.connect() fails because of a security restriction.SecureSocket
  Dispatched when a socket has received data.SecureSocket
Property Detail

isSupported

property
isSupported:Boolean  [read-only]

Runtime Versions:  2

Indicates whether secure sockets are supported on the current system.

Secure sockets are not supported on all platforms. Check this property before attempting to create a SecureSocket instance.

serverCertificate

property 
serverCertificate:X509Certificate  [read-only]

Runtime Versions:  3

Holds the X.509 certificate obtained from the server after a secure SSL/TLS connection is established. If a secure connection is not established, this property is set to null.

For more information on X.509 certificates, see RFC2459.

serverCertificateStatus

property 
serverCertificateStatus:String  [read-only]

Runtime Versions:  2

Returns the status of the server's certificate.

The status is CertificateStatus.UNKNOWN until the socket attempts to connect to a server. After validation, the status is one of the strings enumerated by the CertificateStatus class. The connection only succeeds when the certificate is valid and trusted. Thus, after a connect event, the value of serverCertificateStatus is always trusted.

Note: Once the certificate has been validated or rejected, the status value is not updated until the next call to the connect() method. Calling close() does not reset the status value to "unknown".

See also

Constructor Detail

SecureSocket

()Constructor
public function SecureSocket()

Runtime Versions:  2

Creates a new SecureSocket object.

Check SecureSocket.isSupported before attempting to create a SecureSocket instance. If SSL 3.0 or TLS 1.0 sockets are not supported, the runtime will throw an IllegalOperationError.


Throws
IllegalOperationError — When SSL Version 3.0 (and higher) or TLS Version 1.0 (and higher) is not supported.
 
SecurityError — Local untrusted SWF files cannot communicate with the Internet. You can work around this problem by reclassifying this SWF file as local-with-networking or trusted.
Method Detail

addBinaryChainBuildingCertificate

()method
public function addBinaryChainBuildingCertificate(certificate:ByteArray, trusted:Boolean):void

Runtime Versions:  3

Adds an X.509 certificate to the local certificate chain that your system uses for validating the server certificate. The certificate is temporary, and lasts for the duration of the session.

Server certificate validation relies on your system's trust store for certificate chain building and validation. Use this method to programmatically add additional certification chains and trusted anchors.

On Mac OS, the System keychain is the default keychain used during the SSL/TLS handshake process. Any intermediate certificates in that keychain are included when building the certification chain.

The certificate you add with this API must be a DER-encoded X.509 certificate. If the trusted parameter is true, the certificate you add with this API is considered a trusted anchor.

For more information on X.509 certificates, see RFC2459.

Parameters

certificate:ByteArray — A ByteArray object containing a DER-encoded X.509 digital certificate.
 
trusted:Boolean — Set to true to designate this certificate as a trust anchor.


Throws
ArgumentError — When the certificate cannot be added.

connect

()method 
public function connect(host:String, port:int):void

Runtime Versions:  2

Connects the socket to the specified host and port using SSL or TLS.

When you call the SecureSocket.connect() method, the socket attempts SSL/TLS handshaking with the server. If the handshake succeeds, the socket attempts to validate the server certificate. If the certificate is valid and trusted, then the secure socket connection is established, and the socket dispatches a connect event. If the handshake fails or the certificate cannot be validated, the socket dispatches an IOError event. You can check the certificate validation result by reading the serverCertificateStatus property after the IOError event is dispatched. (When a connect event is dispatched, the certificate status is always trusted.)

If the socket was already connected, the existing connection is closed first.

Parameters

host:String — The name or IP address of the host to connect to.
 
port:int — The port number to connect to.


Events
connect:Event — Dispatched when a network connection has been established.
 
ioError:IOErrorEvent — Dispatched if a host is specified and an input/output error occurs that causes the connection to fail. This includes SSL/TLS handshake errors and failure to successfully validate the host's server certificate.
 
securityError:SecurityErrorEvent — Dispatched if a call to Socket.connect() attempts to connect either to a server that doesn't serve a socket policy file, or to a server whose policy file doesn't grant the calling host access to the specified port. For more information on policy files, see "Website controls (policy files)" in the ActionScript 3.0 Developer's Guide and the Flash Player Developer Center Topic: Security.

Throws
IOError — When you don't specify a host and the connection fails.
 
SecurityError — When you specify a socket port less than zero or higher than 65535.
Event Detail

close

Event
Event Object Type: flash.events.Event
property Event.type = flash.events.Event.CLOSE

Runtime Versions:  2

Dispatched when the server closes the socket connection.

The close event is dispatched only when the server closes the connection; it is not dispatched when you call the Socket.close() method.

The Event.CLOSE constant defines the value of the type property of a close event object.

This event has the following properties:

PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe object whose connection has been closed.

connect

Event  
Event Object Type: flash.events.Event
property Event.type = flash.events.Event.CONNECT

Runtime Versions:  2

Dispatched when a network connection has been established.

The Event.CONNECT constant defines the value of the type property of a connect event object.

This event has the following properties:

PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe Socket or XMLSocket object that has established a network connection.

ioError

Event  
Event Object Type: flash.events.IOErrorEvent
property IOErrorEvent.type = flash.events.IOErrorEvent.IO_ERROR

Runtime Versions:  2

Dispatched when an input or output error occurs that causes a send or receive operation to fail.

When a server certificate cannot be validated, the error event dispatched is an IOError. In this case, you can check the serverCertificateStatus property to determine the cause of the problem.

Defines the value of the type property of an ioError event object.

This event has the following properties:

PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
errorIDA reference number associated with the specific error (AIR only).
targetThe network object experiencing the input/output error.
textText to be displayed as an error message.

securityError

Event  
Event Object Type: flash.events.SecurityErrorEvent
property SecurityErrorEvent.type = flash.events.SecurityErrorEvent.SECURITY_ERROR

Runtime Versions:  2

Dispatched when a call to SecureSocket.connect() fails because of a security restriction.

A security error event is dispatched when code running in Flash Player or in AIR outside the application security sandbox attempts to connect to a server in a different domain or to a port lower than 1024 and the server does not provide a policy file that allows the connection. Note that code running within the AIR application sandbox can connect to a server at any domain and on ports below 1024 without a policy file.

The SecurityErrorEvent.SECURITY_ERROR constant defines the value of the type property of a securityError event object.

This event has the following properties:

PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe network object reporting the security error.
textText to be displayed as an error message.

See also

socketData

Event  
Event Object Type: flash.events.ProgressEvent
property ProgressEvent.type = flash.events.ProgressEvent.SOCKET_DATA

Runtime Versions:  2

Dispatched when a socket has received data. Events of type socketData do not use the ProgressEvent.bytesTotal property.

Defines the value of the type property of a socketData event object.

This event has the following properties:

PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event.
bytesLoadedThe number of items or bytes loaded at the time the listener processes the event.
bytesTotal0; this property is not used by socketData event objects.
targetThe socket reporting progress.