Signing iOS mobileconfig files with your certificate

If you’ve ever used Apple’s iPhone Configuration Utility, you’ve probably noticed that it says ‘Unsigned’ when you send the .mobileconfig file to your device. To sign the profile, export or email the config file to yourself, have your certificate files handy, and type the following:

openssl smime \
-sign \
-signer your-cert.pem \
-inkey your-priv-key.pem \
-certfile TheCertChain.pem \
-nodetach \
-outform der \
-in ConfigProfile.mobileconfig \
-out ConfigProfile_signed.mobileconfig

The files you’ll need are:

your-cert.pem – this is the certificate you’ve been issued
your-priv-key.pem – this is your private key
TheCertChain.pem – this is the certificate chain (optional, in some cases)
ConfigProfile.mobileconfig – This is the unsigned copy of your configuration profile

The original instructions are located here.

Discovering all Bonjour services

To discover all Bonjour services, do the following:

NSNetServiceBrowser
searchForServicesOfType: @"_services._dns-sd._udp."
inDomain: @""

It will return data in the following form:

NSNetService
name = "_workstation"
type = "_tcp.local."
domain = "."

All this documentation taken from here.

Fixing Mac OS X 10.6’s ping command (aka, removing Request timeout for icmp_seq #)

If you are like me, and annoyed that OS X 10.6’s ping command displays the following text when it cannot reach a host:

Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2

Then you’ll be happy for the fix. You can either download the source code to the ping command from Apple and edit it yourself, or you can download my pre-compiled copy.

If you choose to edit it yourself, you’ll want to comment out lines 977 and 978 so they look like this:

// if (!(options & F_QUIET))
// printf("Request timeout for icmp_seq %ld\n", ntransmitted - 2);

Then just type ‘gcc ping.c’ and you’ll end up with a file called a.out, which you can use to replace /sbin/ping, or put in your local ~/bin directory if you’ve got one.

HP Print Driver Crash when printing to networked printers

I ran into an issue recently where any application would crash when printing to a network printer. Our environment is unique in that we are printing to a Windows print server (using Guest privileges), but users on the network are logging in using the Novell client.

The crash would not happen with generic Microsoft drivers that came with Windows XP, but it would happen with any HP-branded drivers. Our first workaround was just to use PCL or PostScript drivers that closely matched the printer, and hope for the best.

In the end, we found out that when printing with the HP drivers, it would write to a file in the Windows directory called hpmnwun.ini. The contents it would write were:


[NWUSERNAME]
NOVELL=1
NWUSERNAME=testuser

Fixing the issue was a two step process:

1: Erase the contents of the file
2: Change the NTFS Permissions of the file to make it read-only by all users (even Administrators)

I think this forces the HP drivers to print to the printer in the standard Windows printer sharing way. When the HP drivers detect the Novell client installed, it writes the NWUSERNAME info to the file and must try to print in an ‘NDPS friendly’ way, which causes the application to crash when printing to a standard Windows shared printer and not a NDPS printer.

Adding Printers to OS X from the Command Line

After a little searching, I found out you can add printers to OS X from the command line using this syntax:

lpadmin -p Printer_Name -L "Printer Location" -E -v lpd://x.x.x.x -P /Library/Printers/PPDs/Contents/Resources/en.lproj/Printer_Driver.gz

If you don’t specify the -P option, it will not show up in your Print or Printer Setup dialogs. If you want to include the generic PPD, it is located here:

/System/Library/Frameworks/ApplicationServices.framework/Versions \ /A/Frameworks/PrintCore.framework/Versions/A/Resources/Generic.ppd

That path is all one line, with no spaces.

Synchronizing data between different computers and OS’s with Dropbox

About a week ago I installed Dropbox, and I have to recommend it to anybody who needs to sync their files between machines. I have a group of Macs that I use to sync data between, and I used to use iDisk, but Dropbox is so much quicker that I can’t see myself using iDisk anymore. Also, the syncing between Linux and Mac OS X works great – I haven’t got a chance to test the Windows client yet, but I’m sure it works just as good.

If you sign up with this link, you’ll get an extra 256MB, and so will I.

Printing 3×5 cards on Epson LQ-590 or LQ-300 impact printers

With Windows XP, you can define custom paper sizes (such as 3×5 cards) by doing the following:

Start -> Printers and Faxes -> File -> Server Properties

In this dialog, you can define a 3×5 card. The problem is, with the LQ-590 and LQ-300 drivers, these paper sizes do not show up as options when you try and print. Any paper size below 4 inches in height will disappear from your printing options.

To get around this, install the LQ-570 driver (the one that is built into Windows XP). This driver will let you use a 3×5 sized form.

Leopard’s SSH Agent not working

My Leopard SSH agent was not working after upgrading a Macbook Pro. I was using a few other applications in the past to manage my SSH keys – in fact, I didn’t even know this was a feature until the new install on a Mac Pro worked without me installing the ‘keychain’ app from fink, or a number of other solutions that I had tried in the past.

To fix this, I had to edit the ~/.MacOSX/environment.plist file. In that file, there is an entry for SSH_AUTH_SOCK which needs to be removed. I just removed the the section that looked like:

<key>SSH_AUTH_SOCK</key>
<string>/tmp/503/SSHKeychain.sock</string>

The text may differ slightly on your computer.

Leopard Error -5002 when connecting to AFP shares

When connecting to AFP shares in the new Mac OS X 10.5 (Leopard), you may get a -5002 error when the server only supports clear text passwords. To resolve, either disable clear text passwords on the server side, or change the following plist:

~/Library/Preferences/com.apple.AppleShareClient.plist

You need to change the afp_cleartext_allow value to “Yes” “true” or “1” (depending on the current values you see, either “false” or a “0”).

Here’s an excerpt from my file:


...
<key>afp_cleartext_allow</key>
<true />
<key>afp_cleartext_warn</key>
<integer>0</integer>
<key>afp_default_name</key>
<string></string>
...