Fix a stack smash when SHA2 certificates are used
From https://jira.opensciencegrid.org/browse/SOFTWARE-1333
Fix compilation problems when strndup is already defined
Merge branch 'ellert-2.x' into fix/VOMS-516
fix VOMS-516

The fix is mostly based on the patch provided by Matthias.
In addition the CN is now based on the SHA1 of the *request*
public key. The same string is also used for the serial number.