x509_get_default_name tries to get FQDN before hostname now.

This commit is contained in:
Armin Novak 2015-08-25 17:44:03 +02:00
parent 1abd652530
commit d557690426

View File

@ -306,9 +306,25 @@ char* x509_name_parse(char* name, char* txt, int* length)
char* x509_get_default_name()
{
CHAR* computerName;
CHAR* computerName = NULL;
DWORD nSize = 0;
if (GetComputerNameExA(ComputerNamePhysicalDnsFullyQualified, NULL, &nSize) ||
GetLastError() != ERROR_MORE_DATA)
goto fallback;
computerName = (CHAR*)calloc(nSize, 1);
if (!computerName)
goto fallback;
if (!GetComputerNameExA(ComputerNamePhysicalDnsFullyQualified, computerName, &nSize))
goto fallback;
return computerName;
fallback:
free(computerName);
if (GetComputerNameExA(ComputerNamePhysicalNetBIOS, NULL, &nSize) ||
GetLastError() != ERROR_MORE_DATA)
return NULL;