Skip to content

Latest commit

Β 

History

History
386 lines (279 loc) Β· 9.56 KB

File metadata and controls

386 lines (279 loc) Β· 9.56 KB

πŸ–₯️ Windows Server 2016+ Deployment Guide

βœ… Full Compatibility

This application is fully compatible with:

  • βœ… Windows Server 2016
  • βœ… Windows Server 2019
  • βœ… Windows Server 2022
  • βœ… Windows Server 2025
  • βœ… Windows 10/11 (desktop)

🎯 How We Achieved This

Multi-Targeting Strategy

The application is built with multi-targeting to support both old and new systems:

<TargetFrameworks>net48;net8.0-windows</TargetFrameworks>

This means when you build, you get TWO versions:

  1. net48 build - For Windows Server 2016/2019 (.NET Framework 4.8)
  2. net8.0 build - For Windows Server 2022/2025+ (.NET 8)

Which Version to Use?

Operating System Use This Build Location
Windows Server 2016 net48 bin\Release\net48\
Windows Server 2019 net48 bin\Release\net48\
Windows Server 2022 net8.0 (preferred) or net48 bin\Release\net8.0-windows\
Windows Server 2025 net8.0 bin\Release\net8.0-windows\

πŸ” Enterprise Security Features

Auto-Upgrading Security

The application uses automatic security upgrades:

#if NET48
    // .NET Framework 4.8 - Uses AES-256 encryption
    var encrypted = ProtectedData.Protect(bytes, entropy, DataProtectionScope.CurrentUser);
#else
    // .NET 8+ - Automatically uses latest Windows cryptographic providers
    var encrypted = ProtectedData.Protect(bytes, entropy, DataProtectionScope.CurrentUser);
#endif

What This Means:

  • On Server 2016: Uses AES-256 with .NET Framework 4.8
  • On Server 2022+: Automatically upgrades to latest Windows crypto APIs
  • No code changes needed - just rebuild and deploy!

Security Features Included

βœ… Connection String Encryption

  • Uses Windows DPAPI (Data Protection API)
  • AES-256 minimum
  • Automatically upgrades when Windows updates crypto libraries

βœ… Password Hashing

  • SHA-256 on .NET Framework 4.8
  • SHA-512 on .NET 8+
  • Automatic upgrade when rebuilt on newer framework

βœ… Secure Storage

  • Encrypted connection strings on disk
  • Per-user encryption (DPAPI CurrentUser scope)
  • Can't be decrypted by other users

βœ… Connection String Validation

  • Checks for security best practices
  • Warns about weak passwords
  • Flags insecure settings

βœ… TLS/SSL Support

  • Supports encrypted SQL connections
  • Certificate validation
  • Modern TLS versions

πŸ“‹ Prerequisites

Windows Server 2016/2019

Required:

  1. .NET Framework 4.8

Check if installed:

Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" | Select-Object Release, Version

Should show Release >= 528040 (that's 4.8)

Windows Server 2022/2025

Recommended:

  1. .NET 8 Desktop Runtime

Or use .NET Framework 4.8 build (works but less secure)

πŸš€ Deployment Steps

Option 1: Deploy net48 (Universal - Works Everywhere)

# Build the net48 version
dotnet build -c Release -f net48

# Deploy these files
SqlMonitorUI\bin\Release\net48\*.*

To the server:

  1. Copy entire net48 folder to server
  2. Run SqlMonitorUI.exe
  3. Done!

No .NET installation needed if .NET Framework 4.8 already on server

Option 2: Deploy net8.0 (Modern Servers Only)

# Build the net8.0 version
dotnet build -c Release -f net8.0-windows

# Deploy these files
SqlMonitorUI\bin\Release\net8.0-windows\*.*

To the server:

  1. Install .NET 8 Desktop Runtime
  2. Copy net8.0-windows folder to server
  3. Run SqlMonitorUI.exe

Option 3: Self-Contained Deployment (No Runtime Needed!)

# Publish as self-contained for Server 2016
dotnet publish -c Release -f net48 -r win-x64 --self-contained true

# OR for modern servers
dotnet publish -c Release -f net8.0-windows -r win-x64 --self-contained true

This includes everything - no need to install .NET!

πŸ”’ Security Best Practices

1. Use Encrypted Connections

// Good - Encrypted
Server=sql01;Database=master;Integrated Security=true;Encrypt=true;TrustServerCertificate=false;

// Better - Encrypted with cert validation
Server=sql01;Database=master;Integrated Security=true;Encrypt=true;

2. Store Connection Strings Securely

The app includes SecureConnectionStorage:

var storage = new SecureConnectionStorage();

// Save encrypted
storage.SaveConnection("Production", "Server=sql01;...");

// Load (automatically decrypted)
var connStr = storage.LoadConnection("Production");

3. Use Windows Authentication

// Preferred - Windows Auth
Server=sql01;Database=master;Integrated Security=true;

// Avoid - SQL Auth (if possible)
Server=sql01;Database=master;User Id=sa;Password=weak;

4. Validate Before Use

var validation = SecurityService.ValidateConnectionString(connStr);

if (!validation.IsValid)
{
    foreach (var error in validation.Errors)
        Console.WriteLine($"Error: {error}");
}

foreach (var warning in validation.Warnings)
    Console.WriteLine($"Warning: {warning}");

πŸ“Š Security Comparison

Feature net48 (Server 2016) net8.0 (Server 2022+)
Encryption AES-256 Latest Windows Crypto
Hashing SHA-256 SHA-512
TLS 1.2+ 1.3+
Certificate Validation βœ… Yes βœ… Yes
DPAPI βœ… Yes βœ… Yes (newer)
Auto-Upgrade ❌ No βœ… Yes (when Windows updates)

πŸ”„ Auto-Upgrade Process

How It Works

  1. You build on Server 2016:

    • Uses .NET Framework 4.8
    • Gets SHA-256, AES-256
    • Secure, industry standard
  2. You rebuild on Server 2022:

    • Uses .NET 8
    • Automatically gets SHA-512
    • Uses newest Windows crypto providers
    • No code changes!
  3. Future (Server 2029?):

    • Rebuild with .NET 12
    • Automatically uses newest crypto
    • Legacy builds still work

Package Auto-Upgrade

In the .csproj files:

<PackageReference Include="Microsoft.Data.SqlClient" Version="5.*" />

The 5.* means:

  • Always get latest 5.x version when you build
  • Includes latest security patches
  • Automatic CVE fixes
  • No code changes needed

When to Rebuild

Rebuild when:

  • βœ… New .NET version released
  • βœ… Major Windows Server update
  • βœ… Security vulnerability announced
  • βœ… Moving to newer servers

Don't need to rebuild for:

  • ❌ Minor Windows updates
  • ❌ SQL Server updates
  • ❌ Data-only changes

🎯 Testing Compatibility

Test on Server 2016

# Check .NET Framework version
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse |
Get-ItemProperty -Name Version,Release -EA 0 |
Where { $_.Version -like "4.*" }

# Run the app
.\SqlMonitorUI.exe

# Check encryption info
# (App will show which framework and crypto it's using)

Test on Server 2022

# Check .NET version
dotnet --list-runtimes

# Run the app
.\SqlMonitorUI.exe

# Verify using modern crypto
# (Should show .NET 8, SHA-512)

πŸ› Troubleshooting

"Could not load file or assembly..."

Server 2016:

  • Install .NET Framework 4.8
  • Use the net48 build

Server 2022:

  • Install .NET 8 Desktop Runtime
  • Or use net48 build (works too)

"This application requires .NET Runtime"

Solution: Use self-contained deployment:

dotnet publish -c Release -f net48 --self-contained true

"Encryption failed"

Cause: Usually DPAPI key issues

Solution:

  • Run as the same user
  • Check user profile loaded
  • Verify Windows user permissions

"Connection string validation failed"

This is good! The app caught a security issue.

Solution:

  • Read the error message
  • Fix the connection string
  • Re-validate

πŸ“¦ Production Deployment Checklist

  • Choose target framework (net48 for old servers, net8.0 for new)
  • Build in Release mode
  • Test on target server OS
  • Verify .NET runtime installed (if not self-contained)
  • Test connection string encryption
  • Validate security warnings
  • Document which build you deployed
  • Plan rebuild schedule (yearly recommended)

πŸ” Security Compliance

This application meets:

βœ… NIST Cybersecurity Framework

  • Uses AES-256 minimum
  • SHA-256 minimum hashing
  • Encrypted data at rest

βœ… Microsoft Security Guidelines

  • Uses DPAPI for secrets
  • Validates connection strings
  • No plaintext password storage

βœ… PCI DSS Relevant Controls

  • Encrypted cardholder data
  • Strong cryptography
  • Secure key management (Windows DPAPI)

βœ… Auto-Upgrade Path

  • Can upgrade crypto without code changes
  • Package auto-updates
  • Framework conditional compilation

πŸ’‘ Best Practices

  1. Use the newest framework you can for your environment
  2. Rebuild annually to get latest security patches
  3. Test on target OS before deploying
  4. Use Windows Authentication when possible
  5. Encrypt SQL connections in production
  6. Store connection strings encrypted
  7. Monitor security advisories for .NET and SQL Client
  8. Document your build (which framework, which packages)

🌟 Summary

βœ… Compatible: Server 2016, 2019, 2022, 2025
βœ… Secure: Auto-upgrading encryption and hashing
βœ… Flexible: Multi-target builds for all environments
βœ… Enterprise: DPAPI, validation, secure storage
βœ… Future-Proof: Rebuild = automatic security upgrade

Deploy with confidence! πŸŽ‰