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

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

?? ??? ??????

??????

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


???????

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

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

????? ????? ???? Visual C# .NET:
  1. ??? ????? Visual Studio .NET.
  2. ?? ??????? ??? ? ??? ??? ???? ?? ???? ??? ???????.
  3. ??? ????? Project ? ???? ??? Visual C# ????????.
  4. ??? ????? ? ???? ??? ????? ???? ??????.
  5. ??? ??????? HashConfigCs.
  6. ???? ??? ?????.

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

???? ????????? ???????? ??????? ????????? ???? ?? ??????? ?? ??? ???????:
  • ??????? ?????? ?? ??? ????? ?????? ????????? ?? ????? ??? decryptionKey.
  • ??????? ??????? ?? ??? ????? ?????? ????????? ?? ????? ??? validationKey.
?????? ???????? ???????? ???? ????? ??????? ?????? ??? ?????? ?? ????? ?????? ???? ????? ??? ????? ??? ???????. ??? ????? ???? ?????? ??????? ????? ?????? ??? ????? ?????? ????? ?????? ????????? ?? ????? .config.

?????? ?? ????? ???? ???? ???? ??? ?????? ????? ??? ?????? ???? ??? ??????? ?? ??? ???????. ??? ???? ??????? ??? ???? 24 ???? ?????? ??? ????? ??????? ??????? 48 ???? ?? ??? ??? ????? ???????. ????? ??????? ?? decryptionKey ?? 8 ?? 24. ???? ??? ??? ????? ????? ?? 16 ???? ????? ???????? ??????? (DES) ?? 48 ???? ??????? ?? ????? Triple DES ??? ???????. ????? ??????? ?? validationKey ?? 20 ??? 64. ???? ??? ??? ????? ?????? ?? 40 ??? 128 ???? ?? ???. ???? ??????? ?? ????????? ???????? ??????? <machinekey> ?????? ???? ????? ???? ????? ?? ??? Machine.config.

Add the following code to a .cs file:
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();
        }
    }
}
				

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

???? ???? ????? ???????.

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


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

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

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

???? ?? ?? ?????? <machinekey>?? ?????? ??????? ????? (??? ?? ?????????? AutoGenerate ?????? ?? ?????? <machinekey>) ??? ????? ??? ?? ???????????? ???????:
  • ??? ??????? ?????? ???????.
  • ??? ????? ???? ???? ????? ?? ??? StateServer.
  • ??? ???? ???? ????? ????? ??? ????? ??? ???? ????? ??? enableViewStateMAC ??? True ???? ???????.

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

??? ?? ?????? machineKey ???? ??? ??? ????? ??? ?? ??????? ???????:
  • ??? ??????? "?????? ???????".
  • ??? ????? ???? ???? ????? ?? ??? StateServer.
  • ????? ???? ???? ????? ????? ??? ????? ??? ??? enableViewStateMac ??? ??????? ???? ???????.

?????

?????? ??? ??????? ??????? ???? ??? ????? ???????? ??????? ?????? ?? "????? ??????? ?? Microsoft:
301240????? ????? ?????? ?????? ??? ??????? ?? ??????? ASP.NET ???????? C# .NET
311495????? ????? ?????? ??????? ??? ????? ?? ???????? ???????? ??? ??????? ?? ??????? ASP.NET ???????? Visual C# .NET
306590INFO: ???? ???? ??? ???? ASP.NET?
307626INFO: ???? ???? ??? ????? ASP.NET

???????

???? ???????: 312906 - ????? ??? ??????: 05/????? ???????/1426 - ??????: 3.10
????? ???
  • Microsoft ASP.NET 1.0
  • Microsoft Visual C# .NET 2002 Standard Edition
  • Microsoft ASP.NET 1.1
  • Microsoft Visual C# .NET 2003 Standard Edition
????? ??????: 
kbmt kbconfig kbhowtomaster kbsecurity kbstate KB312906 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????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