source: swig/perl/SSL_keyid.c

Last change on this file was 2e92c62, checked in by Mei <mei@…>, 11 years ago

1) take out debug statement and fix SSL_keyid.c's compiler warning

  • Property mode set to 100644
File size: 398 bytes
Line 
1#include <stdlib.h>
2
3#include <openssl/x509.h>
4
5char *SSL_keyid(void *ptr) {
6    int i;
7    unsigned char sha1_hash[SHA_DIGEST_LENGTH];
8    char *hash;
9    X509 *x = (X509 *)ptr;
10
11    X509_pubkey_digest(x, EVP_sha1(), sha1_hash, NULL);
12
13    hash = malloc(SHA_DIGEST_LENGTH * 2 + 1);
14    for (i = 0; i < SHA_DIGEST_LENGTH; ++i)
15        sprintf(&hash[2*i], "%02x", sha1_hash[i]);
16
17    return hash;
18}
Note: See TracBrowser for help on using the repository browser.