نمایش نتایج 1 تا 2 از 2

نام تاپیک: مشکل در حفاظت از app.config

  1. #1

    مشکل در حفاظت از app.config

    با سلام و خسته نباشید
    دوستان من app.config برنامه خودم را با استفاده از تابع زیر encrypt کردم و روی کامپیوتر خودم به درستی عمل می کند و لی زمانی که برنامه روی سیستم دیگری کپی می شود پیام خطا می دهد که نمی توان dycrypt انجام دهد لطفا راهنمایی کنید

    static void ToggleConfigEncryption(string exeConfigName)
    {
    // Takes the executable file name without the
    // .config extension.
    try
    {
    // Open the configuration file and retrieve
    // the connectionStrings section.
    Configuration config = ConfigurationManager.OpenExeConfiguration(exeConfi gName);


    ConnectionStringsSection section =
    config.GetSection("connectionStrings")
    as ConnectionStringsSection;

    if (section.SectionInformation.IsProtected)
    {
    // Remove encryption.
    // section.SectionInformation.UnprotectSection();
    }
    else
    {
    // Encrypt the section.
    section.SectionInformation.ProtectSection(
    "DataProtectionConfigurationProvider");
    }
    // Save the current configuration.
    AppSettingsSection st2 = config.GetSection("appSettings") as AppSettingsSection;
    if (!st2.SectionInformation.IsProtected)
    st2.SectionInformation.ProtectSection("DataProtect ionConfigurationProvider");

    // config.Sections.Add(
    config.Save(ConfigurationSaveMode.Full);

    // Console.WriteLine("Protected={0}",
    // section.SectionInformation.IsProtected);
    }
    catch (Exception ex)
    {
    Console.WriteLine(ex.Message);
    }
    }

    تو کامپیوتر دیگری که اجرا می کنم پیام زیر نشون داده میشه
    untitled.JPG

  2. #2
    کاربر تازه وارد آواتار Sp|R|T
    تاریخ عضویت
    اردیبهشت 1390
    پست
    72

    نقل قول: مشکل در حفاظت از app.config

    سلام

    چند وقت پیش همین مشکل رو داشتم که به این نتیجه و جواب رسیدم:

    How are you encrypting the data on the Windows XP machine? Did you  copy the config file from your Windows 7 machine by any chance?
    The Encryption API uses a unique encryption key for your account/machine to encrypt the data. That means that a config file encrypted on one machine cannot be decrypted on another.
    So you will have to encrypt the config file on the XP machine, or use a custom encryption key which you then have to install onto the machine in order for you to read the connection string.


    و

    "Key" is involved Encryption/Decryption always. If you just enrypt a  file on your PC and share the file to anyone they can't decrypt the data  without the key. So you have to share the key along with the file.  Atleast you have to hard code the key in  your source code or keep it resources.


    مختصر:

    app.config فقط روی همون کامپیوتری که اِنکریپت شده میتونه dycrypt بشه ! در واقع کلید این قفل فقط توی همون کامپیوتر خودتون وجود داره که قفل رو باز کنه و در کامپیوتر های دیگه معنی نداره !

    یا هم اینکه یه کلید واسش بسازین و روی کامپیوتر های دیگه نصب کنید؛ که این کار عملآ انگار app.config رو انکریپت نکردین !

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •