1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-22 17:39:53 +03:00

OpenVPN certificate authorization with cn_username in 'email' format

This commit is contained in:
Alexey Ivanov 2024-04-12 23:08:24 +05:00
parent ca832a9cef
commit 71d71e51db

View File

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