CredWrite stores an empty set of credentials for TLS now, avoiding initial credential prompt
This commit is contained in:
parent
91f87aa3c7
commit
a33da0d8d5
@ -107,6 +107,9 @@
|
||||
<ProjectReference Include="..\lib\PAP\build\PAP.vcxproj">
|
||||
<Project>{36b0cf8a-7794-46c3-8099-825ba962b4c7}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\lib\TLS\build\TLS.vcxproj">
|
||||
<Project>{4d40cb8a-812e-4f12-b23a-31af743878e8}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\lib\WinStd\build\WinStd.vcxproj">
|
||||
<Project>{47399d91-7eb9-41de-b521-514ba5db0c43}</Project>
|
||||
</ProjectReference>
|
||||
|
@ -40,7 +40,7 @@ static int CredWrite()
|
||||
return -1;
|
||||
}
|
||||
|
||||
eap::credentials_pap cred(g_module);
|
||||
eap::credentials_pap cred_pap(g_module);
|
||||
|
||||
// Prepare identity (user name).
|
||||
{
|
||||
@ -50,7 +50,7 @@ static int CredWrite()
|
||||
bool is_last;
|
||||
dec.decode(identity_utf8, is_last, pwcArglist[1], (size_t)-1);
|
||||
|
||||
MultiByteToWideChar(CP_UTF8, 0, identity_utf8.data(), (int)identity_utf8.size(), cred.m_identity);
|
||||
MultiByteToWideChar(CP_UTF8, 0, identity_utf8.data(), (int)identity_utf8.size(), cred_pap.m_identity);
|
||||
}
|
||||
|
||||
// Prepare password.
|
||||
@ -61,7 +61,7 @@ static int CredWrite()
|
||||
bool is_last;
|
||||
dec.decode(password_utf8, is_last, pwcArglist[2], (size_t)-1);
|
||||
|
||||
MultiByteToWideChar(CP_UTF8, 0, password_utf8.data(), (int)password_utf8.size(), cred.m_password);
|
||||
MultiByteToWideChar(CP_UTF8, 0, password_utf8.data(), (int)password_utf8.size(), cred_pap.m_password);
|
||||
}
|
||||
|
||||
// Generate target name (aka realm).
|
||||
@ -71,7 +71,7 @@ static int CredWrite()
|
||||
target_name = pwcArglist[3];
|
||||
} else {
|
||||
// Get the realm from user name.
|
||||
LPCWSTR _identity = cred.m_identity.c_str(), domain;
|
||||
LPCWSTR _identity = cred_pap.m_identity.c_str(), domain;
|
||||
if ((domain = wcschr(_identity, L'@')) != NULL)
|
||||
target_name = domain + 1;
|
||||
else if ((domain = wcschr(_identity, L'\\')) != NULL)
|
||||
@ -94,7 +94,7 @@ static int CredWrite()
|
||||
}
|
||||
#endif
|
||||
try {
|
||||
cred.store(target_name.c_str());
|
||||
cred_pap.store(target_name.c_str());
|
||||
} catch(win_runtime_error &err) {
|
||||
OutputDebugStr(_T("%hs (error %u)\n"), err.what(), err.number());
|
||||
return 2;
|
||||
@ -103,6 +103,18 @@ static int CredWrite()
|
||||
return 2;
|
||||
}
|
||||
|
||||
// Store empty TLS credentials.
|
||||
eap::credentials_tls cred_tls(g_module);
|
||||
try {
|
||||
cred_tls.store(target_name.c_str());
|
||||
} catch(win_runtime_error &err) {
|
||||
OutputDebugStr(_T("%hs (error %u)\n"), err.what(), err.number());
|
||||
return 3;
|
||||
} catch(...) {
|
||||
OutputDebugStr(_T("Writing credentials failed.\n"));
|
||||
return 3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -20,8 +20,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../lib/PAP/include/Config.h"
|
||||
#include "../lib/PAP/include/Credentials.h"
|
||||
#include "../lib/TLS/include/Credentials.h"
|
||||
#include "../lib/EAPBase/include/Module.h"
|
||||
|
||||
#include <WinStd/Common.h>
|
||||
|
Loading…
x
Reference in New Issue
Block a user