Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8867563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:04:15+00:00 2026-06-14T17:04:15+00:00

I am trying to communicate to a server through SSL. The PEM client file

  • 0

I am trying to communicate to a server through SSL. The PEM client file is consisted of a certificate and an rsa private key.

I managed to convert both the certificate and key to binary DER. I load the DER certificate to SecureSocket succesfully (with function addBinaryChainBuildingCertificate) 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.

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?

EDIT :

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);
        }
    }

}

Result :

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()

If I comment the line :

//mSocket.addBinaryChainBuildingCertificate(key, true);

I get :

SecureSocket.isSupported true
certificate 497
key 607
ERROR! Error #2031: Socket Error. URL: 127.0.0.1 : principalMismatch
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:04:17+00:00Added an answer on June 14, 2026 at 5:04 pm

    Firstly:

    The “principal mismatch” indicates that the common name of the certificate on the secured server does not match the DNS name that you are connecting to.

    Considering that you are making a connect to localhost (127.0.0.1) there will most certainly be a mismatch. Flash sockets are particularly strict when it comes to making secure connections and there is no mechanism to override security features unlike other runtimes (e.g. .NET and Java). The following must be true:

    1. The certificate common name mush match the DNS name (there is a relaxation here for ‘star’ certs i.e. a cert for *.bob.com is considered valid for mr.bob.com)
    2. The certificate must be valid in terms of expiry and trust chain

    Secondly:

    You seem to have some misconception on how certificates work. You do not need to add any certificates using the addBinaryChainBuildingCertificate() method if the server certificate is issued by a trusted root authority i.e. the certificate that signed the server certificate is in the local trust store of the target device.

    To illustrate:

    • I have a certificate for this.is.awesome.com installed on my server and a DNS entry that resolves this.is.awesome.com to my server’s IP Address
    • This certificate is issued by the Entrust L1C certificate authority.
    • The L1C certificate is in turn issued by the Entrust 2048 root authority.

    On my PC I have the Entrust 2048 Root authority installed in my Trusted Root certificate store.
    However I do not have the L1C certificate installed. When I attempt to connect to this.is.awesome.com the connection will fail as the server certificate cannot be validated against the L1C authority.

    If I add the DER encoded L1C certificate using addBinaryChainBuildingCertificate() then the connection will succeed. The server certificate will be validated against the L1C certificate which will in turn be validated against the 2048 Root certificate which is a trusted root.

    To summarize:

    Your connection issues seem to stem from your attempt to connect to localhost.
    Try adding an entry to your HOSTS file that maps the name on your certificate to 127.0.0.1 and then connecting to that name. If that fails check the issuer chain on your certificate and add the chain of issuers by calling addBinaryChainBuildingCertificate() once for each issuing certificate in the chain. The final or root certificate should be marked as such by passing true as the second parameter to addBinaryChainBuildingCertificate()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to let a (android) client communicate with a server. Sending data client
I'm trying to communicate with Flash Media Server through the Responder class because I
I am trying to build a simple server to communicate with Arduino and store
I am trying to communicate to a client the likely-hood of losing files in
Im have a lab-environment in VMware with a WS2008R2-server and a W7-client. Im trying
I am trying to communicate with my Minecraft server on the RCON port. I
I'm trying TCP file transfer on Linux. After establishing the connection, the server should
I'm developing a client and a server file transfer application with C++ sockets over
I'm trying to communicate with a server that uses DataInputStream.readUTF and DataOutputStream.writeUTF. I did
I'm trying to communicate with a third party server using curl. The authentication system

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.