Fix stack smash from SHA2 certificates

I forward a patch from OSG that fixes a stack corruption when SHA2 certificates are used. For more information see https://jira.opensciencegrid.org/browse/SOFTWARE-1333

The request also contains a commit that fixes compilation problems when strndup is defined as a macro