Note that there are some explanatory texts on larger screens.

plurals
  1. POFlash SecureSocket and RSA private key
    primarykey
    data
    text
    <p>I am trying to communicate to a server through SSL. The PEM client file is consisted of a certificate and an rsa private key.</p> <p>I managed to convert both the certificate and key to binary DER. I load the DER certificate to SecureSocket succesfully (with function <strong><em>addBinaryChainBuildingCertificate</em></strong>) but when I try to connect to the server I get a "principal mismatch" error. If I try to use the aforementioned function to load the DER key, I get a "wrong parameter" error.</p> <p>I suppose the "principal mismatch" is because I haven't loaded the private key. But I see no function to load an RSA key to SecureSocket. Is there any solution to this? Do I need to communicate to the server with only a certificate but remove the key from the equation?</p> <p><strong>EDIT :</strong></p> <p>Code :</p> <pre><code>package { import flash.display.Sprite; import flash.net.SecureSocket; import flash.net.URLLoader; import flash.events.ProgressEvent; import flash.events.Event; import flash.events.IOErrorEvent; import flash.net.URLLoaderDataFormat; import flash.net.URLRequest; import flash.utils.ByteArray; public class TestSSL2 extends Sprite { private var mSocket:SecureSocket = new SecureSocket(); private var certFile:String = "ca.der"; private var keyFile:String = "key.der"; private var cert:ByteArray; private var key:ByteArray; public function TestSSL2() { trace("SecureSocket.isSupported",SecureSocket.isSupported); var urlLoader:URLLoader = new URLLoader(); urlLoader.addEventListener(Event.COMPLETE, certLoaded, false, 0, true); urlLoader.dataFormat = URLLoaderDataFormat.BINARY; urlLoader.load(new URLRequest(certFile)); } private function certLoaded(e:Event):void { cert = (e.target as URLLoader).data; trace("certificate",cert.length); mSocket.addBinaryChainBuildingCertificate(cert, true); var urlLoader:URLLoader = new URLLoader(); urlLoader.addEventListener(Event.COMPLETE, keyLoaded, false, 0, true); urlLoader.dataFormat = URLLoaderDataFormat.BINARY; urlLoader.load(new URLRequest(keyFile)); } private function keyLoaded(e:Event):void { key = (e.target as URLLoader).data; trace("key",key.length); mSocket.addBinaryChainBuildingCertificate(key, true); mSocket.connect("127.0.0.1", 3000); mSocket.addEventListener(Event.CONNECT, socketConnected); mSocket.addEventListener(IOErrorEvent.IO_ERROR, onError); mSocket.addEventListener(ProgressEvent.SOCKET_DATA, socketData ); } private function onError(error:IOErrorEvent):void { trace("ERROR!",error.text,":",mSocket.serverCertificateStatus); } private function socketConnected(e:Event):void { trace("Connected", e); } private function socketData(e:*):void { var data:String; data = mSocket.readUTFBytes(mSocket.bytesAvailable); trace(data); } } } </code></pre> <p>Result :</p> <pre><code>SecureSocket.isSupported true certificate 497 key 607 ArgumentError: Error #2004: One of the parameters is invalid. at flash.net::SecureSocket/addBinaryChainBuildingCertificate() at TestSSL2/keyLoaded() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at flash.net::URLLoader/onComplete() </code></pre> <p>If I comment the line :</p> <p><code>//mSocket.addBinaryChainBuildingCertificate(key, true);</code></p> <p>I get :</p> <pre><code>SecureSocket.isSupported true certificate 497 key 607 ERROR! Error #2031: Socket Error. URL: 127.0.0.1 : principalMismatch </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload