×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Jun 2011
    Location
    Poland
    Posts
    9

    KErrArgument after CX509Certificate::NewLC

    Hi,
    I have a problem when I try to load public RSA key extracted from PEM file in Base64 format.
    I don't know what can be wrong, but CX509Certificate::NewLC(buf8BinaryData) leaves with KErrArgument.

    I'll be very thankful for any help

    Code:
            _LIT8(KPublicKey, "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnXXKF/PF4Igzicn78sztUvo3if3+MSHTMy+uLGmoJ7SBe089GfG6oxbp2+KchEaMsMhewFuTx34asVAe2J87l0YMDn/lEg0cROSw8FsG+1XEaJLJFpEgpn6aW0XlM2MXbtHyLVa+stN0e/hDtBdjpQQFH7ifSJReopgKwy+j5YMOrNnzTiJXvjExXsSHXtdov6XDWGWAGqYzkjM/1Phq0FaacFK3RTNdAwBfJnXPhQk+bdXZNZkP7P/Ksb1lls97s12dJaBtevvtTMMdPtogFyVfu40ajQLexNHTqBsxv6s9//8rd5L4DeYx6jJFh/d2skpqf6gi2BWrCG0wz/aOYwIDAQAB");
    
            //...
            
    	TImCodecB64 b64dec;
    	b64dec.Initialise();
    	RBuf8 buf8BinaryData;
    			
    	RDebug::Printf("public key length: %d",KPublicKey().Length());
    	
    	buf8BinaryData.Create(KPublicKey().Length());
    	
    	buf8BinaryData.Copy(KText());
    	b64dec.Decode(KPublicKey(), buf8BinaryData);
    	
    	RDebug::Printf("rbuf length: %d",buf8BinaryData.Length());
    	
    	CX509Certificate *cert;
    	TRAP(err,cert = CX509Certificate::NewLC(buf8BinaryData));
    	RDebug::Printf("err: %d",err); //err == KErrArgument
    	RDebug::Printf("algor: %d",cert->PublicKey().AlgorithmId());
    	CX509RSAPublicKey* key = CX509RSAPublicKey::NewLC(cert->PublicKey().KeyData());
    	CRSAPKCS1v15Encryptor* encryptor = CRSAPKCS1v15Encryptor::NewLC(*key);

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: KErrArgument after CX509Certificate::NewLC

    I would first fix other problems, basically you should never get to that line, since your TRAP(err,cert = CX509Certificate::NewLC(buf8BinaryData)); should already crash the process, since you are not popping the cert out before leaving the TRAP.

  3. #3
    Registered User
    Join Date
    Jun 2011
    Location
    Poland
    Posts
    9

    Re: KErrArgument after CX509Certificate::NewLC

    Oh dear, you are right...
    I forgot about that fact with TRAP, probably because I add some code here and there to see what is going on.

    Thanks for your suggestion.
    Beside the problem with TRAPD I can see err: -6 in debug output so I guess that something is wrong with modulus and exponent.

    Do you see any other errors ??

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: KErrArgument after CX509Certificate::NewLC

    I would not know the API too well, so first you should see that it is executing as you would want it to execute, and then do see which exact line is giving the error. Also do check wiki for any additional examples for the API.

  5. #5
    Registered User
    Join Date
    Jun 2011
    Location
    Poland
    Posts
    9

    Re: KErrArgument after CX509Certificate::NewLC

    Ok, Thanks !!

  6. #6
    Nokia Developer Expert
    Join Date
    Jun 2006
    Posts
    28

    Re: KErrArgument after CX509Certificate::NewLC

    It look like you are passing public key to CX509Certificate class. Public key and X509 certificates are not the same.

Similar Threads

  1. Replies: 0
    Last Post: 2010-02-23, 09:56
  2. CX509Certificate and private keys
    By dolbyz in forum Symbian Signed Support, Application Packaging and Distribution and Security
    Replies: 3
    Last Post: 2009-11-11, 07:24
  3. CX509Certificate::NewL Error
    By kamesh.smartdude in forum Wired and Wireless interfaces (Closed)
    Replies: 2
    Last Post: 2008-11-25, 11:00
  4. CX509Certificate::NewL Error
    By kamesh.smartdude in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2008-11-25, 10:54
  5. KErrArgument in CObexClient Get()
    By micmen in forum Symbian
    Replies: 6
    Last Post: 2005-07-11, 10:59

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×