1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-22 09:29:52 +03:00

Merge pull request #1980 from Alexey-I/master

OpenVPN certificate authorization with cn_username in 'email' format
This commit is contained in:
Ilya Shipitsin 2024-04-14 10:58:27 +02:00 committed by GitHub
commit 465df16505
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6773,7 +6773,6 @@ PACK *PackLoginWithOpenVPNCertificate(char *hubname, char *username, X *x)
p = NewPack();
PackAddStr(p, "method", "login");
PackAddStr(p, "hubname", hubname);
if (IsEmptyStr(username))
{
@ -6782,12 +6781,26 @@ PACK *PackLoginWithOpenVPNCertificate(char *hubname, char *username, X *x)
FreePack(p);
return NULL;
}
UniToStr(cn_username, sizeof(cn_username), x->subject_name->CommonName);
PackAddStr(p, "username", cn_username);
if (strchr(cn_username, '@') != NULL)
{
PackAddStr(p, "username", strtok(cn_username, "@"));
PackAddStr(p, "hubname", strtok(NULL, ""));
}
else
{
PackAddStr(p, "username", cn_username);
PackAddStr(p, "hubname", hubname);
}
}
else
{
PackAddStr(p, "username", username);
PackAddStr(p, "hubname", hubname);
}
PackAddInt(p, "authtype", AUTHTYPE_OPENVPN_CERT);