Fix segfault on PKey.check() when there is no private key
diff --git a/OpenSSL/crypto/pkey.c b/OpenSSL/crypto/pkey.c
index 27ea4d4..711306d 100644
--- a/OpenSSL/crypto/pkey.c
+++ b/OpenSSL/crypto/pkey.c
@@ -124,6 +124,11 @@
         return NULL;
     }
 
+    if (self->only_public) {
+        PyErr_SetString(PyExc_TypeError, "public key only");
+        return NULL;
+	}
+
     if (self->pkey->type == EVP_PKEY_RSA) {
         RSA *rsa;
         rsa = EVP_PKEY_get1_RSA(self->pkey);