Changeset 314 for binary-improvements/MapRendering
- Timestamp:
- Jan 18, 2018, 5:00:29 PM (7 years ago)
- Location:
- binary-improvements/MapRendering
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/ModInfo.xml
r311 r314 5 5 <Description value="Render the game map to image map tiles as it is uncovered" /> 6 6 <Author value="Christian 'Alloc' Illy" /> 7 <Version value="2 2" />7 <Version value="23" /> 8 8 <Website value="http://7dtd.illy.bz" /> 9 9 </ModInfo> -
binary-improvements/MapRendering/Web/OpenID.cs
r244 r314 7 7 using System.Text; 8 8 using System.Text.RegularExpressions; 9 using System.Security.Cryptography.X509Certificates; 10 using System.Reflection; 9 11 10 12 namespace AllocsFixes.NetConnections.Servers.Web … … 14 16 private static Regex steamIdUrlMatcher = new Regex (@"^http:\/\/steamcommunity\.com\/openid\/id\/([0-9]{17,18})"); 15 17 18 private static readonly X509Certificate2 caCert = new X509Certificate2 (Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location) + "/steam-rootca.cer"); 19 private static readonly X509Certificate2 caIntermediateCert = new X509Certificate2 (Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location) + "/steam-intermediate.cer"); 20 21 private static readonly bool verboseSsl = false; 22 16 23 static OpenID () { 17 24 ServicePointManager.ServerCertificateValidationCallback = (srvPoint, certificate, chain, errors) => { 18 if (errors == SslPolicyErrors.None) 25 if (errors == SslPolicyErrors.None) { 26 if (verboseSsl) { 27 Log.Out ("Steam certificate: No error (1)"); 28 } 19 29 return true; 30 } 20 31 21 Log.Out ("Steam certificate error: {0}", errors); 32 X509Chain privateChain = new X509Chain (); 33 privateChain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck; 22 34 35 privateChain.ChainPolicy.ExtraStore.Add (caCert); 36 privateChain.ChainPolicy.ExtraStore.Add (caIntermediateCert); 37 38 if (privateChain.Build (new X509Certificate2 (certificate))) { 39 // No errors, immediately return 40 privateChain.Reset (); 41 if (verboseSsl) { 42 Log.Out ("Steam certificate: No error (2)"); 43 } 44 return true; 45 } 46 47 if (privateChain.ChainStatus.Length == 0) { 48 // No errors, immediately return 49 privateChain.Reset (); 50 if (verboseSsl) { 51 Log.Out ("Steam certificate: No error (3)"); 52 } 53 return true; 54 } 55 56 // Iterate all chain elements 57 foreach (X509ChainElement chainEl in privateChain.ChainElements) { 58 if (verboseSsl) { 59 Log.Out ("Validating cert: " + chainEl.Certificate.Subject); 60 } 61 // Iterate all status flags of the current cert 62 foreach (X509ChainStatus chainStatus in chainEl.ChainElementStatus) { 63 if (verboseSsl) { 64 Log.Out (" Status: " + chainStatus.Status); 65 } 66 if (chainStatus.Status == X509ChainStatusFlags.NoError) { 67 // This status is not an error, skip 68 continue; 69 } 70 if (chainStatus.Status == X509ChainStatusFlags.UntrustedRoot && chainEl.Certificate == caCert) { 71 // This status is about the cert being an untrusted root certificate but the certificate is one of those we added, ignore 72 continue; 73 } 74 // This status is an error, print information 75 Log.Warning ("Steam certificate error: " + chainEl.Certificate.Subject + " ### Error: " + chainStatus.Status); 76 privateChain.Reset (); 77 return false; 78 } 79 } 80 81 foreach (X509ChainStatus chainStatus in privateChain.ChainStatus) { 82 if (chainStatus.Status != X509ChainStatusFlags.NoError && chainStatus.Status != X509ChainStatusFlags.UntrustedRoot) { 83 Log.Warning ("Steam certificate error: " + chainStatus.Status); 84 privateChain.Reset (); 85 return false; 86 } 87 } 88 89 // We didn't find any errors, chain is valid 90 privateChain.Reset (); 91 if (verboseSsl) { 92 Log.Out ("Steam certificate: No error (4)"); 93 } 23 94 return true; 24 95 }; -
binary-improvements/MapRendering/Web/Web.cs
r311 r314 237 237 238 238 if (_req.Url.AbsolutePath.StartsWith ("/session/verify")) { 239 ulong id = OpenID.Validate (_req); 240 if (id > 0) { 241 WebConnection con = connectionHandler.LogIn (id, _req.RemoteEndPoint.Address.ToString ()); 242 _con = con; 243 int level = GameManager.Instance.adminTools.GetAdminToolsClientInfo (id.ToString ()).PermissionLevel; 244 Log.Out ("Steam OpenID login from {0} with ID {1}, permission level {2}", _req.RemoteEndPoint.ToString (), con.SteamID, level); 245 return level; 246 } else { 247 Log.Out ("Steam OpenID login failed from {0}", _req.RemoteEndPoint.ToString ()); 239 try { 240 ulong id = OpenID.Validate (_req); 241 if (id > 0) { 242 WebConnection con = connectionHandler.LogIn (id, _req.RemoteEndPoint.Address.ToString ()); 243 _con = con; 244 int level = GameManager.Instance.adminTools.GetAdminToolsClientInfo (id.ToString ()).PermissionLevel; 245 Log.Out ("Steam OpenID login from {0} with ID {1}, permission level {2}", _req.RemoteEndPoint.ToString (), con.SteamID, level); 246 return level; 247 } else { 248 Log.Out ("Steam OpenID login failed from {0}", _req.RemoteEndPoint.ToString ()); 249 } 250 } catch (Exception e) { 251 Log.Error ("Error validating login:"); 252 Log.Exception (e); 248 253 } 249 254 } -
binary-improvements/MapRendering/WebAndMapRendering.csproj
r279 r314 22 22 </PropertyGroup> 23 23 <ItemGroup> 24 <Reference Include="System">25 <HintPath>..\7dtd-binaries\System.dll</HintPath>26 <Private>False</Private>27 </Reference>28 24 <Reference Include="LogLibrary"> 29 25 <HintPath>..\7dtd-binaries\LogLibrary.dll</HintPath> … … 44 40 <Reference Include="System.Xml"> 45 41 <HintPath>..\7dtd-binaries\System.Xml.dll</HintPath> 42 <Private>False</Private> 43 </Reference> 44 <Reference Include="System"> 45 <HintPath>..\7dtd-binaries\System.dll</HintPath> 46 46 <Private>False</Private> 47 47 </Reference> … … 103 103 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 104 104 </None> 105 <None Include="steam-intermediate.cer"> 106 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 107 </None> 108 <None Include="steam-rootca.cer"> 109 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 110 </None> 105 111 </ItemGroup> 106 112 </Project>
Note:
See TracChangeset
for help on using the changeset viewer.