Showing posts with label Mac. Show all posts
Showing posts with label Mac. Show all posts

Sunday, December 22, 2013

How to resolve XCode's “valid signing identity not found” error

Generally, this error is caused because of a mismatch between a provisioning profile and a private key. It can also be that you even do not own a private key that makes your identity identified to the provisioning profile which are you working with.


First Resolution
Double-check that the profile that you have got from Apple Developer Program is the correct one that you are supposed to have. Sometimes organizations have multiple profiles for each team and although you have a correct private key, you own the wrong provisioning profile.

Second Resolution
You do not own the private key of the provisioning profile and/or identity that you are using. You need to own a private key file with .p12 extension in order for your identity to be validated. Whoever have created your identity (in case you work in a  team of developers, it could be someone else), has it on his/her machine when he has created the profile and/or identity. you need to get this key from that person or reissue a new private key (which takes some time) in order to resolve the issue.


If this sounds too confusing and does not make any sense for you, follow my step-to-step guide to How to sign your MacOSX application code with codesign?

Saturday, December 21, 2013

How to sign your MacOSX application code with codesign?

A Brief Preface: I recently realized that the documentation for signing your Mac OSX applications with codesign is distributed across many documents which is extremely hard to find (You can find those documents in the "more to read" section of this post). Also, in the documentation it has been assumed that you will sign your code with XCode which is not always the case. As you may know, XCode is mainly used for development with Objective C for MacOSX and iPhone but a lot of Mac OSX applications are written in C/C++ and Java which XCode does not support any feature for those project types and makes the signing process extremely hard.

Now, let us start:

1. Go to Apple's Developer Program's Member Center. Go to member center. Write your credentials and enter.

NOTE: If you have not registered in Apple's Developer Program, you need to do so before you can sign your code.

2. Under Developer Program Resources, click on Certificates, Identifiers and Profiles. Under Mac Apps Click on Certificates. Then go to your certificate and then Click on Download. Now you have downloaded the Certificate.


3. Find the certificate file that you downloaded, and run it.
Keychain Access program will be opened by default and will put your Certificate under login keychains and certificates category:





4. Download your private key from the Apple's website: In the downloaded folder you will find a key file with .p12 extension which is Mac’s public key (PKCS12) format. Again, open the file and automatically it will be attached to the certificate you just downloaded.


Check whether it is already there as you expect it.

5. Next Step is to get Developer’s ID. Right click on the certificate of Mac developer profile which you want the code to be signed with and click on “Get info”. On the new windows, scroll down and get the SHA1 fingerprint of the certificate:


Remove the white-spaces and put it under $DEVELOPER_ID in your sign command or if you have one, in your build script. Also, you need to add the requirement for signing. Read about it on Mac Developer Documentation: Apple's Codesign Requirement Specification

Remark: One example of requirements can be of following (This example uses Mozilla's XULWrapper platform):

CODESIGN_REQUIREMENTS="=designated => anchor apple generic  and identifier \"org.webapp.xulwrapper\" and ((cert leaf[field.1.2.840.113635.100.6.1.9] exists) or ( certificate 1[field.1.2.840.113635.100.6.2.6] exists and certificate leaf[field.1.2.840.113635.100.6.1.13] exists  and certificate leaf[subject.OU] = \"FOO123BAR1\" ))"

/usr/bin/codesign -s "$DEVELOPER_ID" -v \
   --requirements "$CODESIGN_REQUIREMENTS" \
   "$APPDIR"

6. You can sign the code now. Run the above command and you should be good to go.

Further References:

Tuesday, April 16, 2013

Run multiple instances of JBoss AS7 on the same machine (Mac + Linux)

NOTE: This tutorial assumes you have a working JBoss server running on port 8080.

1. Copy your existing JBOSS directory and rename it to jboss_maint (or something similar)

2. Go inside the jboss_maint/standalone/standalone.xml file. Find the <management-interface> element in the files. It looks something like the followings:

<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
<socket-binding name="management-native" interface="management" port="${jboss.management.https.port:9999}"/>
<socket-binding name="management-http" interface="management" port="${jboss.management.https.port:9990}"/> 
<socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9443}"/> 
<socket-binding name="ajp" port="8009"/> 
<socket-binding name="http" port="8080"/> 
<socket-binding name="https" port="8443"/> 
<socket-binding name="osgi-http" interface="management" port="8090"/> 
<socket-binding name="remoting" port="4447"/>
<socket-binding name="txn-recovery-environment" port="4712"/> 
<socket-binding name="txn-status-manager" port="4713"/>
<outbound-socket-binding name="mail-smtp"> 
<remote-destination host="localhost" port="25"/> 
</outbound-socket-binding> 
</socket-binding-group> 
As you can see above, the public interface is being used as the default interface (In case you are interested, the definition of the public interface resides in <interface> element inside the same file).

Since we are using the same IP address for both maintenance and development servers, we only need to offset all ports to 100. You can achieve this via changing the port-offset attribute of <socket-binding-group> property:

<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:100}">
Save the changes, go inside your jboss_maint/bin directory:

cd server/jboss_maint/bin
Start up your new server:
./standalone.sh

Now you should be able to browse to localhost:8180 and see the index page of JBOSS AS7. (Remember that 8080 plus the preset offset value (100) equals 8180).