Q: Why is phpseclib not signing this cert corrrectly? I try to sign a key with phpseclib and when I decode the result with openssl I get the following:
140513785948000:error:0D07209B:asn1 encoding routines:ASN1_get_object:too long:asn1_lib.c:142:
140513785948000:error:0D068066:asn1 encoding routines:ASN1_CHECK_TLEN:bad object header:tasn_dec.c:1306:
140513785948000:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:tasn_dec.c:381:Type=X509
140513785948000:error:0906700D:PEM routines:PEM_ASN1_read_bio:ASN1 lib:pem_oth.c:83:
Why is it doing this?
(This bug took me a while to figure out, so I figured I'd help the next person with this issue out by posting it here)

A: The problem is that I was loading the key but forgetting to initialize it.
$publicKey = new Crypt_RSA();
$publicKey->loadKey($key);
$publicKey->setPublicKey(); //this line was missing

