Dienstag, 8. Dezember 2009

OS X: Create PDFs from command line

Re-Blogging from Mac OSX Hints:

(...) I recently read documentation for cups-pdf, however, and found that cupsfilter command is sufficient for most of my own tasks in its bare form!

For example, to print 80-column ASCII plaintext (the majority of my code), I can use this:

$ cupsfilter foo.txt > foo.pdf

If you find the output of that command a bit verbose (as I do), you can send the errors silently to the null device using this version:

$ cupsfilter foo.txt > foo.pdf 2> /dev/null

There are many ways to wrap this simple command even more conveniently, but I'll omit those here for now. The reason this method is ideal is because it uses built-in routines in OS X; any time you can take advantage of these, do, because many of the core technologies are significantly faster and more secure than third-party alternatives.

Of course, your mileage may vary :-).


Dienstag, 1. Dezember 2009

OS X: OpenSSL Create Certificate Request

Eher für mich selbst zur Erinnerung, aber natürlich auch für alle die ab und an Zertifikate (z.B. bei RapidSSL) requesten müssen.

Erstmal die OpenSSL Config überarbeiten, ist eigentlich selbsterklärend. Keysize aus 2048 und alle Defaults ausfüllen, dann ist es später einfacher mit der Command Line:

mate /System/Library/OpenSSL/openssl.cnf

Dann den eigentlichen Key generieren:

openssl genrsa -des3 -out sampleprivate.key 2048

Jetzt den Certificate Request (PKCS#10) generieren:

openssl req -new -key sampleprivate.key -sha1 -out sampleprivate.csr -config /System/Library/OpenSSL/openssl.cnf

Zur Kontrolle nochmal alles in plain text anzeigen lassen:

openssl req -text -in sampleprivate.csr

Der Request muss jetzt zum Zertifikats-Anbieter, bei der Auswahl zwischen den $15 und $1.500 Zertifikaten der verschiedenen Anbieter hilft vielleicht dieser Merksatz weiter:

Anyone who selects a public CA on a factor other than price fails to understand the trust models that underlie today’s use of CAs
— Lucky Green

Nach Abschluss des mehr oder weniger ästhetischen Web-Wizard, der Bezahlung der vergoldeten Bits und der wahnsinnig aufwändigen Identitäts-Verifikation ("und Sie sind ganz bestimmt Herr Müller von Microsoft?") kommt auf irgendeine Art das Zertifikat zurück - das speichern wir unter "samplecertificate.cer" und daraus können wir dann ein PKCS#12 (P12) bauen:

openssl pkcs12 -export -out samplepackage.p12 -in samplecertificate.cer -inkey sampleprivate.key

Das wars.