-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SqlSecureConnection: Unable to finish successfully with ForcedEncryption #1888
Comments
Confirmed. Good catch! I will create a separate issue for this. |
Creating a new issue for this. |
Please see #1891 (comment) and see if you can help getting the output to catch the error you mentioned. |
An optional parameter I was thinking we could evaluate the property |
I must also say that the work you put into the details in this issue was very much appreciated. |
@johlju, I will try to take a look at this afternoon. I've got a few meetings but hopefully I can get to it, if not I might not be able to get to it until Thursday. I should just be able to merge in the changes to what I'm running locally now and see if it works. Thanks for the quick response on this and the complement. 😃 Always glad to help out when I can. |
I had a chance to test today and I think it will work. My config got further but it is still erroring out, however I don't think it is related to this change. I will have more time tomorrow to double check and then get back to you for sure. |
The errors came from the |
Cool, lets merge the PR then. |
- `SqlSecureConnection` - Added new parameter `ServerName` that will be used as the host name when restarting the SQL Server instance. The specified value should be the same name that is used in the certificate (issue #1888).
Problem description
I am currently trying to implement a SqlSecureConnection resource with a certificate and forced encryption but have run into an issue with it not being able to execute successfully. I think I have narrowed the problem down to two issues.
The first is this line. The problem is with the fact that the
ServerName
is hardcoded tolocalhost
which once the thumbprint of the certificate is set results in theConnect-SQL
cmdlet throwing the following exception.The
Connect-SQL
cmdlet is working as expected but this becomes an issue here when waiting for the restart. TheErrorActionPrefernce
is masking that theConnect-SQL
cmdlet is throwing an exception about the SSL connection which will never resolve itself. This results in$testConnectionServerObject
always beingnull
which ends up waiting for a loop control condition that will never occur.The first issue led me to the second issue which is with the
Stopwatch
timer. The intention is that the loop end after 120 seconds, assuming the default timeout value, but it's not because the control statement is incorrect. The loop control should be looking atTotalSeconds
notElapsed.Seconds
becauseElapsed.Seconds
will never be greater than60
.I've included these in the same issue as they are related but I can submit the incorrect loop control as a separate issue if you'd prefer.
Verbose logs
DSC configuration
Suggested solution
For the first issue with the hardcoded
localhost
value for theServerName
I'm not sure if you'd want to do anything other thanadd
ServerName
to the resource and then pass that through to theRestart-SqlServerice
cmdlet. Once the certificate is set and encryption is forced the only way to connect is by using the FQDN. There might be another way to get the data by just trying to figure out what the FQDN should be or using localhost as a default but I don't think that would be easier than just addingServerName
property to the resource and defaulting to a value oflocalhost
if it's not supplied.For the issue with the loop control this simply just modify the
Elapsed.Seconds
toElapse.TotalSeconds
SQL Server edition and version
SQL Server PowerShell modules
Operating system
PowerShell version
SqlServerDsc version
The text was updated successfully, but these errors were encountered: