??????? ?????????? ??? ????? ?? ??? ????? C# .NET ?? ????? ?? ????? ?? ????? ?? ??? ???? ????

???? ?????? ???? ??????
???? ID: 312906 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

??????

?? ???? ????? ???? ?? ?? ???????????, ?????????? ?? ??????? ???? ???? ??????? ?? ??????? ?? ??? ????? ???? ?? ??? ????? ????? ?? ??? ???? ????? ????? ?? ??? ?? ???? ??? ???????? ?? ????? ?? ???? ???validationKey, ??decryptionKey?? ????????? <machinekey>??? ??????</machinekey><system.web></system.web>Machine.config ????? ??? ?????


??????????

????? ???? outlines ???????? ?????????, ??????????, ??????? ??????, ?? ???? ???? ???:
  • Microsoft Windows 2000 ?? Microsoft Windows XP
  • Microsoft .NET ?????
  • Microsoft ??????? ????? ?????? (IIS)

????????? ?????

?? ????? C# .NET ????? ????????? ?????:
  1. Visual Studio .NET ?? ??????? ?????
  2. ?????????? ??,????? ????-????? ????, ?? ???? ????????????.
  3. ?? ???????????????? ??????????? ????,????? C# ?????????.
  4. ?? ???????????????????? ????,????? ?????????.
  5. ????????? ?? ???HashConfigCs.
  6. ????? ????,OK.

????? ????? ???? ?? ??? ??? ?????

????? ??? ???? ???? ?????? ?? ??? ?? ???? ??:
  • ???? ???? ?? ????? ?? ??? ????? ???? ???? ?? ?? ?????? ?? ??????decryptionKey??????? ???
  • ????? ??????????? ????? ?? ??? ????? ???? ???? ?? ?? ?????? ?? ?????? ??validationKey??????? ???
??? ????? ?????? ??? ?????? ?? ???? ?????? ???? ?? ?????? ????? ?? ??? ????? ?????? generator ?? ????? ???? ??? ????? ?????? ?? ??? ???, ?? ??? ?????? .Config ??????? ??? ????? ?? ??? ??????? ?? ?? ???????????? ???????? ??? ???????? ????

???:???????????? ???????? ?? ?? ????? ??? ?? ???? ?????? ?? ???? ??? ??? ?? ?? ??? ???? ??? ?????? ?? ???, ??? ?? ???? ????? ?? ??? 24 ?????? ????????? ????, ??? ???? ???????? ?? ????? ??? 48 ?????? ???????? ?? ???? ????? ????? ?? ???decryptionKey8 ?? 24 ??? ?? ???? ??????????? ?? ??? ??? 16 ???? ????? ????? ?? ???? (DES) ?? ?? 48 ???? ????? Triple DES, ?? ??? respectively. ?? ??? ????? ???validationKey20 ???? ?? ??? 64 ???? ?? ????? ???????? 40 ?? ????? ??? 128 ?????? ???? ?? ???? ?????? ?? ??? ?? ?? ???? ??<machinekey></machinekey>???? ?? ?? ?? ????????? ?? ???? ??? ?? ?? Machine.config ???? ??? ????????

??? .cs ????? ??? ????? ??? ??????:
using System;
using System.Text;
using System.Security.Cryptography;

namespace Crypto
{
    public class KeyCreator
    {
        public static void Main(String[] args)
        {			
            String[] commandLineArgs = System.Environment.GetCommandLineArgs();
            string decryptionKey = CreateKey(System.Convert.ToInt32(commandLineArgs[1]));
            string validationKey = CreateKey(System.Convert.ToInt32(commandLineArgs[2]));

            Console.WriteLine("<machineKey validationKey=\"{0}\" decryptionKey=\"{1}\" validation=\"SHA1\"/>", validationKey, decryptionKey);
        }	

        static String CreateKey(int numBytes) 
        {
            RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
            byte[] buff = new byte[numBytes];

            rng.GetBytes(buff);
            return BytesToHexString(buff);
        }

        static String BytesToHexString(byte[] bytes) 
        {
            StringBuilder hexString = new StringBuilder(64);

            for (int counter = 0; counter < bytes.Length; counter++) 
            {
                hexString.Append(String.Format("{0:X2}", bytes[counter]));
            }
            return hexString.ToString();
        }
    }
}
				

Hashes ????? ????

?? ?? ????????? ?? ?????? ?? ???? ????

Passing ?????????? ?? ??????? ???????? ?? ???? ??? ?? ?? ???????? ??? ??? ?? ?? ??????? ????????? ?? ????????? ?????? ?????? ?? ???, ??? ?? ????? ????????? HashConfigCs.exe ?? ??? ????? ????? ???? ?????? ?? ???????? ????????? ?? Bin\debug ??????????:
hashconfigcs.exe 24 64
?? ????????? ?? ?????? ?????? ????? ?? ???? ???? ?? ?? ???? ???? ?? ??? ??????? ?? ???? ???:
<machineKey validationKey="21F090935F6E49C2C797F69BBAAD8402ABD2EE0B667A8B44EA7DD4374267A75D7AD972A119482D15A4127461DB1DC347C1A63AE5F1CCFAACFF1B72A7F0A281B"
            decryptionKey="261F793EB53B761503AC445E0CA28DA44AA9B3CF06263B77"
            validation="SHA1"/>
					
???:??? ????? ?????? generator ?? ????? ?? ??? ??, ??????? ?????? ????? ???????? ??? ???


??????????? ????? ?? ?????? ????

  1. Machine.config ????? ?? ?????? ??????
  2. ??????<system.web></system.web>?????? ??? ??????????? ????? ???
  3. ????? ????????? ?? ?????? ?? ??? <machinekey>??? ?? ???????????? ????? ??? <machinekey>??? ???? ?????, ???? ?????</machinekey></machinekey>
  4. ??????????? ????? ???????
  5. IIS ??? farm Machine.config ?????????? ?? ??????? ???? ?? ??? ??? ??? ????? ?? ???????? ?????

?????? ??????

????????? ???? ?? ?? <machinekey>??? ???, ?????? ????? ???????? ?? (??????, ????? ?</machinekey>AutoGenerateoption for attributes in the <machinekey> section) across the Web farm in the following scenarios: </machinekey>
  • When you use Forms authentication.
  • When you run session state in StateServer mode.
  • When you want ViewState to be available across a Web farm because theenableViewStateMACattribute is set toTrue???????? ??? ???

???? ???????

ThemachineKeysection should be the same across the web farm in the following cases:
  • When using Forms Authentication.
  • When you run session state in StateServer mode.
  • When you want viewstate to be available across a web farm since enableViewStateMac is turned on by default.

??????

???????? ??????? ?? ???, ????? ???? ???????? ?? ????? ?? ?????? ?? Microsoft ???????? ??? ?????::
301240???????-?????? ?????????? C# .NET ?? ????? ?? ???? asp.NET ????????? ??? ??????????? ???? ?? ??? ???? ????
311495???????-?????? ?????????? ?? ??? ???-?????? ??????? ????? C# .NET ?? ????? ?? ???? asp.NET ????????? ??? ??????????? ???? ?? ??? ???? ????
306590?????: asp.NET ??????? ????????? ??????
307626?????: asp.NET ??????????? ????????? ??????

???

???? ID: 312906 - ????? ???????: 04 ?????? 2010 - ??????: 2.0
???? ???? ???? ??:
  • Microsoft ASP.NET 1.0
  • Microsoft Visual C# .NET 2002 Standard Edition
  • Microsoft ASP.NET 1.1
  • Microsoft Visual C# .NET 2003 Standard Edition
??????: 
kbconfig kbhowtomaster kbsecurity kbstate kbmt KB312906 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:312906

??????????? ???

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com