Giter Site home page Giter Site logo

SSL Support about reportingservicestools HOT 2 OPEN

microsoft avatar microsoft commented on July 24, 2024
SSL Support

from reportingservicestools.

Comments (2)

HealisticEngineer avatar HealisticEngineer commented on July 24, 2024 2

Hi Guys,

I've created my own solution to the problem, that you could also use.

I've fixed function that was created by @RuiRomano for SQL 2008 to make it work with 2016 and 2017

Also note the wmi call would need to be versioned as I was working with PowerBi Server and SQL 2017 so its version v14 however I did test with SQl 2016 using v13 and that works fine as well.
As I was testing locally I needed to create selfsign so that part can be dropped, however I've kept it in so you can see the end to end how it works.

Get FQDN

$dnsname = ([System.Net.Dns]::GetHostByName((hostname)).HostName)
#Create SSL Certificate (replace with PKI function)
New-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\My -DnsName $dnsname -FriendlyName PBIRS

Get the cert Thumbprint

$certHash = (Get-ChildItem -Path cert:\LocalMachine\My -DnsName $dnsname).Thumbprint

Make cert trusted

$cert = (Get-ChildItem -Path Cert:\LocalMachine\My\$certHash)
Export-Certificate -Cert $cert -FilePath c:\cert.cer
$file = ( Get-ChildItem -Path C:\cert.cer )
$file | Import-Certificate -CertStoreLocation Cert:\LocalMachine\Root

Function

function Set-SSRSSystemConfiguration($sslUrl, $certHash, $sslPort, $ReportServerInstance){
		# https://ruiromanoblog.wordpress.com/2010/05/08/configure-reporting-services-ssl-binding-with-wmi-powershell/
		# The .ToLower() avoids the error “A Secure Sockets Layer (SSL) certificate is not configured on the Web site.”
		$certHash = $certHash.ToLower()
		Write-Output “Configure SSRS SSL binding”
		
		$serverClass = get-wmiobject -namespace "root\Microsoft\SqlServer\ReportServer\RS_$ReportServerInstance\v14\Admin" -class “MSReportServer_ConfigurationSetting”
		
		if ($serverClass -eq $null) { throw “Cannot find wmi class” }
		$lcid = [System.Globalization.CultureInfo]::GetCultureInfo(“pt-PT”).LCID
		$result = $serverClass.RemoveURL(“ReportServerWebService”, $sslUrl, $lcid)
		if (!($result.HRESULT -eq 0)) { write-error $result.Error }
		$result = $serverClass.ReserveURL(“ReportServerWebService”, $sslUrl, $lcid)
		if (!($result.HRESULT -eq 0)) { write-error $result.Error }
		$result = $serverClass.RemoveSSLCertificateBindings(“ReportServerWebService”, $certHash, “0.0.0.0”, $sslPort, $lcid)
		if (!($result.HRESULT -eq 0)) { write-error $result.Error }
		$result = $serverClass.CreateSSLCertificateBinding(“ReportServerWebService”, $certHash, “0.0.0.0”, $sslPort, $lcid)
		if (!($result.HRESULT -eq 0)) { write-error $result.Error }
		$result = $serverClass.RemoveURL(“ReportServerWebApp”, $sslUrl, $lcid)
		if (!($result.HRESULT -eq 0)) { write-error $result.Error }
		$result = $serverClass.ReserveURL(“ReportServerWebApp”, $sslUrl, $lcid)
		if (!($result.HRESULT -eq 0)) { write-error $result.Error }
		$result = $serverClass.RemoveSSLCertificateBindings(“ReportServerWebApp”, $certHash, “0.0.0.0”, $sslPort, $lcid)
		if (!($result.HRESULT -eq 0)) { write-error $result.Error }
		$result = $serverClass.CreateSSLCertificateBinding(“ReportServerWebApp”, $certHash, “0.0.0.0”, $sslPort, $lcid)
		if (!($result.HRESULT -eq 0)) { write-error $result.Error }
		} #close funciton

Call function to configure the SSL binding

Set-SSRSSystemConfiguration "https://$($dnsname):443" $certHash 443 PBIRS

from reportingservicestools.

ronott avatar ronott commented on July 24, 2024

Hey Guys,

Thanks @HealisticEngineer for the TLS function!

For SSRS 2019 I had to add the SetSecureConnectionLevel method, appart from that, works like a charm.

function Set-SSRSSystemConfiguration($sslUrl, $certHash, $sslPort, $ReportServerInstance){
		# https://ruiromanoblog.wordpress.com/2010/05/08/configure-reporting-services-ssl-binding-with-wmi-powershell/
		# The .ToLower() avoids the error “A Secure Sockets Layer (SSL) certificate is not configured on the Web site.”
		$certHash = $certHash.ToLower()
		Write-Output “Configure SSRS SSL binding”

		...

		$result = $serverClass.SetSecureConnectionLevel("1")
		if (!($result.HRESULT -eq 0)) { write-error $result.Error }

		} #close funciton

+1 for adding SSL Support

from reportingservicestools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.