2021年8月28日 星期六

SQL Server 2012 Native Client - QFE才支援TLS 1.2

某次SQL Server伺服器作業系統關閉TLS 1.0和1.1之後,AP程式連DB有問題,後來發現是要安裝新版的SQL Server 2012 Native Client - QFE。原本是安裝舊版的11.0.2100.60(在2012年發佈的)。安裝後需要重新啟動伺服器。

下載Microsoft® SQL Server® 2012 Native Client - QFE (支援TLS 1.2)
https://www.microsoft.com/en-us/download/details.aspx?id=50402

Version:
11.0.7001.0

Date Published:
1/19/2018



升級成新版可以在AP伺服器建立一個 .udl檔案測試和資料庫連線,可參考以下網址
https://success.trendmicro.com/solution/1118930-using-tlsv1-1-or-tlsv1-2-for-communication-between-mssql-server-and-officescan

 
KB3135244 - TLS 1.2 support for Microsoft SQL Server(必看!)
https://support.microsoft.com/en-us/topic/kb3135244-tls-1-2-support-for-microsoft-sql-server-e4472ef8-90a9-13c1-e4d8-44aad198cdbe

 
 

sqlncli.msi安裝程式資訊(
QFE版支援TLS1.2)



sqlncli.msi安裝程式資訊(舊版,不支援TLS1.2)
 

 
 
AP程式的錯誤訊息(Crystal Report版本是11.5,AP伺服器安裝舊版sqlncli.msi,DB伺服器已關閉TLS 1.0和1.1):

System.Runtime.InteropServices.COMException (0x8004100F): Logon failed.

Details:  [Database Vendor Code: 10054 ]

Logon failed.

Details:  [Database Vendor Code: 10054 ]

Error in File C:\Windows\TEMP\XXXXX.rpt:

Unable to connect: incorrect log on parameters.

Details:  [Database Vendor Code: 10054 ]

   at CrystalDecisions.ReportAppServer.Controllers.DatabaseControllerClass.SetTableLocation(ISCRTable CurTable, ISCRTable NewTable)

   at CrystalDecisions.CrystalReports.Engine.Table.set_Location(String value)
 
 
 
Event Log的錯誤訊息:
 
 
 


如果有用到ODBC Driver 11 for SQL Server(msodbcsql.msi)也需要新版才支援TLS1.2
<最新版已經出到17)
https://docs.microsoft.com/zh-tw/sharepoint/security-for-sharepoint-server/enable-tls-1-1-and-tls-1-2-support-in-sharepoint-server-2016

1.1 - 安裝 ODBC Driver 11 for SQL Server 的 TLS 1.2 支援更新

ODBC Driver 11 for SQL Server (適用於 SQL Server 的 ODBC 驅動程式 11) 預設不支援 TLS 1.1 或 TLS 1.2。您必須安裝 ODBC Driver 11 for SQL Server 的 TLS 1.2 支援更新。

CheckClientUpdates.ps1
The PowerShell Script currently supports the following:

Check if SQL Server Native Client can support TLS 1.2
Check if Microsoft ODBC Driver for SQL Server can support TLS 1.2 This script is restricted to work on x64 and x86 platforms


在AP伺服器上檢測SQL Server資料庫驅動程式是否支援TLS 1.2?
支援TLS 1.2


不支援TLS 1.2

 
 
 
 
以下文章參考用,和升級TLS 1.2無關
https://docs.microsoft.com/en-us/sql/connect/oledb/oledb-driver-for-sql-server?view=sql-server-ver15

Different generations of OLE DB Drivers

There are three distinct generations of Microsoft OLE DB providers for SQL Server.

1. Microsoft OLE DB Provider for SQL Server (SQLOLEDB)

The Microsoft OLE DB Provider for SQL Server (SQLOLEDB) still ships as part of Windows Data Access Components. It is not maintained anymore and it is not recommended to use this driver for new development.

2. SQL Server Native Client (SNAC)

Starting in SQL Server 2005 (9.x), the SQL Server Native Client (SNAC) includes an OLE DB provider interface (SQLNCLI) and is the OLE DB provider that shipped with SQL Server 2005 (9.x) through SQL Server 2012 (11.x).

It was announced as deprecated in 2011 and it is not recommended to use this driver for new development. For more information about the SNAC lifecycle and available downloads, refer to SNAC lifecycle explained.

3. Microsoft OLE DB Driver for SQL Server (MSOLEDBSQL)

OLE DB was undeprecated and released in 2018.

The new OLE DB provider is called the Microsoft OLE DB Driver for SQL Server (MSOLEDBSQL). The new provider will be updated with the most recent server features going forward.

 Note

To use the new Microsoft OLE DB Driver for SQL Server in existing applications, you should plan to convert your connection strings from SQLOLEDB or SQLNCLI, to MSOLEDBSQL.

 

KB 4486153:Windows 10和 Windows Server 2019的.NET Framework 4.8

https://support.microsoft.com/zh-tw/topic/%E9%81%A9%E7%94%A8%E6%96%BC-x64-%E6%9B%B4%E6%96%B0%E4%B9%8B-windows-server-2019-windows-10-1709-%E7%89%88%E5%92%8C-windows-10-1803-%E7%89%88%E5%92%8C-windows-10-1809-%E7%89%88%E7%9A%84-microsoft-net-framework-4-8-9e61c44e-08d2-f20d-c890-9ed873d9dba0

 簡介

本文介紹了 Windows 10、版本 1709、Windows 10、版本 1803、Windows Server、版本 1803、Windows 10、版本 1809 和 Windows Server、版本 1809 和 Windows Server 2019 上的 Microsoft .NET Framework 4.8 的更新。

請注意: 從 2020 年 1 月 14 日開始,.NET Framework 4.8 已使用最新的服務更新重新整理。 除了 服務修正程式,2019 年 8 月 13 日發行的 Windows Update 中 , .NET Framework 4.8 產品中沒有任何變更。 如果您已下載並 安裝 8 月發行的更新,則不需要安裝此更新, 否則,請安裝此更新以收到最新的產品位元。

 

https://support.microsoft.com/zh-tw/topic/%E7%94%A8%E6%96%BC-windows-%E7%9A%84-microsoft-net-framework-4-8-%E9%9B%A2%E7%B7%9A%E5%AE%89%E8%A3%9D%E7%A8%8B%E5%BC%8F-9d23f658-3b97-68ab-d013-aa3c3e7495e0

安裝此套件時,將根據您的作業系統安装以下套件或更新:

  • 在 Windows 7 SP1 和 Windows Server 2008 R2 SP1 中,Microsoft.NET Framework 4.8.1 (KB4503548) 在「控制台」下的「程式和功能」中列為已安裝產品。

  • 在 Windows Server 2012 中,Microsoft Windows 的更新 (KB4486081) 位於控制台下的「已安裝更新」中。 在 Windows 8.1 或 Windows Server 2012 R2 中,Microsoft Windows 的更新 (KB4486105) 位於控制台的「已安装更新」當中。

  • 在 Windows 8.1 或 Windows Server 2012 R2 中,Microsoft Windows 的更新 (KB4486105) 位於控制台的「已安装更新」當中。

  • 在 Windows 10 周年更新(版本 1607)、Windows 10 建立者更新 (版本 1703) 和 Windows Sever 2016 中,它在控制台下的「已安裝更新」中被列為 Microsoft Windows 更新 (KB4486129)。

  • 在 Windows 10 秋季建立者的更新版本 1709、Windows 2018 年 4 月 10 日更新 (版本 1803)、Windows 2018 2018 更新 (版本 1809) 和 Windows Server 2019 中,它在控制台的「已安裝更新」下被列為「微軟 Windows 更新 」(KB4486153)。

2020年6月21日 星期日

製作Visual Studio 2019專業版離線安裝檔

因為公司屬於企業組織,根據授權條款不能在公司使用Community版本,但公司連網際網路有管制,需要製作離線安裝檔。

事先到https://docs.microsoft.com/zh-tw/visualstudio/install/create-an-offline-installation-of-visual-studio?view=vs-2019下載vs_professional.exe

離線安裝檔包含.NET web和.NET desktop development和Office development(繁中和英文):
請事先在D磁碟機建立vs2019pro資料夾
使用命令提示字元執行以下指令
vs_professional.exe  --layout D:\vs2019pro --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb --add Component.GitHub.VisualStudio --add Microsoft.VisualStudio.Workload.Office --includeOptional --lang en-US zh-TW



參考資料:
https://docs.microsoft.com/zh-tw/visualstudio/install/create-an-offline-installation-of-visual-studio?view=vs-2019

https://github.com/MicrosoftDocs/visualstudio-docs/blob/master/docs/install/create-an-offline-installation-of-visual-studio.md


For .NET web and .NET desktop development, run:
vs_professional.exe --layout D:\vs2019pro --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb --add Component.GitHub.VisualStudio --includeOptional --lang en-US zh-TW


To create a complete local layout with all features (this will take a long time—we have lots of features!), run:
vs_professional.exe --layout D:\vs2019pro --lang en-US zh-TW


For .NET desktop and Office development, run:
vs_professional.exe --layout D:\vs2019pro --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.Office --includeOptional --lang en-US zh-TW

2020年6月13日 星期六

BinaryFormatter()搭配SerializationBinder類別驗證許可還原序列化的類別

避免Unsafe Deserialization弱點



https://topic.alibabacloud.com/tc/a/-net-c--pilot-type-in-deserialization-using-serializationbinder_1_31_32345296.html

//SerializationBinder的執行類
class ConversionBinder : SerializationBinder
{
    public override Type BindToType(string assemblyName, string typeName)
    {
        //篩選Person類型
        //判斷是否是Person類型,如果是返回Person_ver2
        var curAssName = typeof(Program).Assembly.FullName;
        var person1 = typeof(Person).FullName;
        string finalType = typeName;
        if (assemblyName == curAssName && typeName == person1)
            finalType = typeof(Person_ver2).FullName;
        return Type.GetType(finalType + "," + assemblyName);
    }
}

    var bf = new BinaryFormatter();
    //設定自訂的SerializationBinder對象
    bf.Binder = new ConversionBinder();
    //序列化Person
    bf.Serialize(ms, p1);
ref:
https://www.slideshare.net/MSbluehat/dangerous-contents-securing-net-deserialization?from_action=save
p.27

https://owasp.org/www-community/vulnerabilities/Deserialization_of_untrusted_data