+uschar * cp = NULL;
+BIO * bp = BIO_new(BIO_s_mem());
+
+if (!bp) return badalloc();
+
+if (X509_print_ex(bp, (X509 *)cert, 0,
+ X509_FLAG_NO_HEADER | X509_FLAG_NO_VERSION | X509_FLAG_NO_SERIAL |
+ /* X509_FLAG_NO_SIGNAME is the missing one */
+ X509_FLAG_NO_ISSUER | X509_FLAG_NO_VALIDITY |
+ X509_FLAG_NO_SUBJECT | X509_FLAG_NO_PUBKEY | X509_FLAG_NO_EXTENSIONS |
+ X509_FLAG_NO_SIGDUMP | X509_FLAG_NO_AUX) == 1)
+ {
+ long len = BIO_get_mem_data(bp, &cp);
+
+ /* Strip leading " Signature Algorithm: " and trailing newline */
+ while (*cp && *cp != ':') { cp++; len--; }
+ do { cp++; len--; } while (*cp && *cp == ' ');
+ if (cp[len-1] == '\n') len--;
+
+ cp = string_copyn(cp, len);
+ }
+BIO_free(bp);
+return cp;