I am trying to sign up using DSA from OpenSSL. I have files containing public and private keys.
First of all, I am doing a unicast connection, and everything is fine. After that, I need a multicast UDP connection, and I want to sign the packets. I am trying to use the PEM_read_DSA_PUBKEY() function to load my public key from my certificate, but it does not work. It always returns NULL instead of the DSA structure.
Here you have a simplified version of the code. I compile like this:
gcc -Wall -g -lm prueba.c -o prueba -lcrypto
Any idea? Thanks!
#include <stdio.h> #include <openssl/dsa.h> #include <openssl/pem.h> int main() { FILE *DSA_cert_file = fopen("./certs/cert.pem", "r"); if (DSA_cert_file == NULL) return 1; printf("Certificate read\n"); DSA *dsa = DSA_new(); if((dsa = PEM_read_DSA_PUBKEY(DSA_cert_file, 0, 0, 0)) == NULL) return 1; printf("DSA public key read\n"); return 0; }
source share