Enhanced to try to connect to the ATS with the normalized host name in addition to the host name given by the application calling to get a token to deal with cases where the application is passing a dotted ip address but the
server's certificate has been issued using the server's DNS name.
This commit is contained in:
parent
c25f4f77bf
commit
7cc9385642
@ -663,8 +663,12 @@ ObtainAuthTokenInt(
|
|||||||
bool setupHostEntries = true;
|
bool setupHostEntries = true;
|
||||||
char *pHostNameAnd443 = NULL;
|
char *pHostNameAnd443 = NULL;
|
||||||
char *pHostNameAnd2645 = NULL;
|
char *pHostNameAnd2645 = NULL;
|
||||||
|
char *pNormalizedHostNameAnd443 = NULL;
|
||||||
|
char *pNormalizedHostNameAnd2645 = NULL;
|
||||||
ATSHostEntry serviceHostEntry443 = {{NULL, NULL}, NULL, NULL, 0};
|
ATSHostEntry serviceHostEntry443 = {{NULL, NULL}, NULL, NULL, 0};
|
||||||
ATSHostEntry serviceHostEntry2645 = {{NULL, NULL}, NULL, NULL, 0};
|
ATSHostEntry serviceHostEntry2645 = {{NULL, NULL}, NULL, NULL, 0};
|
||||||
|
ATSHostEntry serviceNormalizedHostEntry443 = {{NULL, NULL}, NULL, NULL, 0};
|
||||||
|
ATSHostEntry serviceNormalizedHostEntry2645 = {{NULL, NULL}, NULL, NULL, 0};
|
||||||
LIST_ENTRY *pListEntry;
|
LIST_ENTRY *pListEntry;
|
||||||
ATSHostEntry *pHostEntryInUse;
|
ATSHostEntry *pHostEntryInUse;
|
||||||
|
|
||||||
@ -709,12 +713,41 @@ ObtainAuthTokenInt(
|
|||||||
serviceHostEntry443.pNameAndPort = pHostNameAnd443;
|
serviceHostEntry443.pNameAndPort = pHostNameAnd443;
|
||||||
serviceHostEntry443.pName = pHostName;
|
serviceHostEntry443.pName = pHostName;
|
||||||
serviceHostEntry443.port = 443;
|
serviceHostEntry443.port = 443;
|
||||||
InsertHeadList(&g_ATSHostList, &serviceHostEntry443.listEntry);
|
InsertHeadList(&g_ATSHostList, &serviceHostEntry443.listEntry);
|
||||||
|
|
||||||
|
// Check if we should also setup host entries using the service's
|
||||||
|
// normalized host name.
|
||||||
|
if (strcmp(pHostName, pNormalizedHostName) != 0)
|
||||||
|
{
|
||||||
|
// The host name given and the normalized name are different. Let's
|
||||||
|
// improve the odds by also trying to utilize the normalized name.
|
||||||
|
pNormalizedHostNameAnd443 = malloc(strlen(pNormalizedHostName) + 5);
|
||||||
|
pNormalizedHostNameAnd2645 = malloc(strlen(pNormalizedHostName) + 6);
|
||||||
|
if (pNormalizedHostNameAnd443 != NULL
|
||||||
|
&& pNormalizedHostNameAnd2645 != NULL)
|
||||||
|
{
|
||||||
|
sprintf(pNormalizedHostNameAnd443, "%s:%d", pNormalizedHostName, 443);
|
||||||
|
sprintf(pNormalizedHostNameAnd2645, "%s:%d", pNormalizedHostName, 2645);
|
||||||
|
|
||||||
|
serviceNormalizedHostEntry2645.pNameAndPort = pNormalizedHostNameAnd2645;
|
||||||
|
serviceNormalizedHostEntry2645.pName = pNormalizedHostName;
|
||||||
|
serviceNormalizedHostEntry2645.port = 2645;
|
||||||
|
InsertHeadList(&g_ATSHostList, &serviceNormalizedHostEntry2645.listEntry);
|
||||||
|
|
||||||
|
serviceNormalizedHostEntry443.pNameAndPort = pNormalizedHostNameAnd443;
|
||||||
|
serviceNormalizedHostEntry443.pName = pNormalizedHostName;
|
||||||
|
serviceNormalizedHostEntry443.port = 443;
|
||||||
|
InsertHeadList(&g_ATSHostList, &serviceNormalizedHostEntry443.listEntry);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DbgTrace(0, "-ObtainAuthTokenInt- Buffer allocation failure\n", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DbgTrace(0, "-ObtainAuthTokenInt- Buffer allocation failure\n", 0);
|
DbgTrace(0, "-ObtainAuthTokenInt- Buffer allocation failure\n", 0);
|
||||||
setupHostEntries = false; // To keep us from de-linking the entries later
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -849,10 +882,18 @@ ObtainAuthTokenInt(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unlink the service host entries if necessary
|
// Unlink the service host entries if necessary
|
||||||
if (setupHostEntries)
|
if (pHostNameAnd443 != NULL
|
||||||
|
&& pHostNameAnd2645 != NULL)
|
||||||
{
|
{
|
||||||
RemoveEntryList(&serviceHostEntry2645.listEntry);
|
RemoveEntryList(&serviceHostEntry2645.listEntry);
|
||||||
RemoveEntryList(&serviceHostEntry443.listEntry);
|
RemoveEntryList(&serviceHostEntry443.listEntry);
|
||||||
|
|
||||||
|
if (pNormalizedHostNameAnd443 != NULL
|
||||||
|
&& pNormalizedHostNameAnd2645 != NULL)
|
||||||
|
{
|
||||||
|
RemoveEntryList(&serviceNormalizedHostEntry2645.listEntry);
|
||||||
|
RemoveEntryList(&serviceNormalizedHostEntry443.listEntry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop user process synchronization
|
// Stop user process synchronization
|
||||||
@ -865,6 +906,12 @@ ObtainAuthTokenInt(
|
|||||||
if (pHostNameAnd2645)
|
if (pHostNameAnd2645)
|
||||||
free(pHostNameAnd2645);
|
free(pHostNameAnd2645);
|
||||||
|
|
||||||
|
if (pNormalizedHostNameAnd443)
|
||||||
|
free(pNormalizedHostNameAnd443);
|
||||||
|
|
||||||
|
if (pNormalizedHostNameAnd2645)
|
||||||
|
free(pNormalizedHostNameAnd2645);
|
||||||
|
|
||||||
free(pNormalizedHostName);
|
free(pNormalizedHostName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user