Skip to content
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

Mono: Fix TLS on DSM7 #5070

Closed
wants to merge 6 commits into from

Conversation

publicarray
Copy link
Member

@publicarray publicarray commented Jan 11, 2022

Description

This should fix the trust store containing expired certificates in mono applications by using a different path. Dependent packages may need to be updated.

Fixes #5051

Checklist

  • Build rule all-supported completed successfully
  • New installation of package completed successfully
  • Package upgrade completed successfully (Manually install the package again)
  • Package functionality was tested
  • Any needed documentation is updated/created

Type of change

  • Bug fix
  • New Package
  • Package update
  • Includes small framework changes
  • This change requires a documentation update (e.g. Wiki)

@publicarray publicarray reopened this Jan 11, 2022
@publicarray publicarray changed the title Mono: Download Certificate bundle. Fixes TLS on DSM7 Mono: Fixe TLS on DSM7 Jan 11, 2022
@publicarray publicarray changed the title Mono: Fixe TLS on DSM7 Mono: Fix TLS on DSM7 Jan 11, 2022
@hgy59
Copy link
Contributor

hgy59 commented Jan 16, 2022

successfully installs and updates certificate store on DS-218+ with DSM 7.0.1 Update 1

2022/01/16 12:31:04     install mono 5.20.1.34-18 Begin preinst
2022/01/16 12:31:04     Begin reload_inst_variables
2022/01/16 12:31:04     End reload_inst_variables
2022/01/16 12:31:04     Begin initialize_variables
2022/01/16 12:31:04     End initialize_variables
2022/01/16 12:31:04     ===> Step preinst. USER= GROUP= SHARE_PATH=
2022/01/16 12:31:04     install mono 5.20.1.34-18 End preinst ret=[0]
2022/01/16 12:31:05     install mono 5.20.1.34-18 Begin /bin/mkdir -p /volume1/@appstore/mono
2022/01/16 12:31:05     install mono 5.20.1.34-18 End /bin/mkdir -p /volume1/@appstore/mono ret=[0]
2022/01/16 12:31:05     install mono 5.20.1.34-18 Begin /bin/rm -rf /volume1/@appstore/mono
2022/01/16 12:31:05     install mono 5.20.1.34-18 End /bin/rm -rf /volume1/@appstore/mono ret=[0]
2022/01/16 12:31:05     install mono 5.20.1.34-18 Begin /bin/mv -f /volume1/@tmp/pkginstall/extract.3keote/package /volume1/@appstore/mono
2022/01/16 12:31:05     install mono 5.20.1.34-18 End /bin/mv -f /volume1/@tmp/pkginstall/extract.3keote/package /volume1/@appstore/mono ret=[0]
2022/01/16 12:31:05     install mono 5.20.1.34-18 Begin /bin/rm -rf /var/packages/mono
2022/01/16 12:31:05     install mono 5.20.1.34-18 End /bin/rm -rf /var/packages/mono ret=[0]
2022/01/16 12:31:05     install mono 5.20.1.34-18 Begin /bin/mkdir -p /var/packages/mono
2022/01/16 12:31:05     install mono 5.20.1.34-18 End /bin/mkdir -p /var/packages/mono ret=[0]
2022/01/16 12:31:05     install mono 5.20.1.34-18 Begin /bin/touch /var/packages/mono/installing
2022/01/16 12:31:05     install mono 5.20.1.34-18 End /bin/touch /var/packages/mono/installing ret=[0]
2022/01/16 12:31:05     install mono 5.20.1.34-18 Begin /bin/mv -f /volume1/@tmp/pkginstall/extract.3keote/INFO /var/packages/mono/INFO
2022/01/16 12:31:05     install mono 5.20.1.34-18 End /bin/mv -f /volume1/@tmp/pkginstall/extract.3keote/INFO /var/packages/mono/INFO ret=[0]
2022/01/16 12:31:05     install mono 5.20.1.34-18 Begin /bin/rm -rf /var/packages/mono/scripts
2022/01/16 12:31:05     install mono 5.20.1.34-18 End /bin/rm -rf /var/packages/mono/scripts ret=[0]
2022/01/16 12:31:05     install mono 5.20.1.34-18 Begin /bin/mv -f /volume1/@tmp/pkginstall/extract.3keote/scripts /var/packages/mono/scripts
2022/01/16 12:31:05     install mono 5.20.1.34-18 End /bin/mv -f /volume1/@tmp/pkginstall/extract.3keote/scripts /var/packages/mono/scripts ret=[0]
2022/01/16 12:31:05     install mono 5.20.1.34-18 Begin /bin/rm -rf /var/packages/mono/WIZARD_UIFILES
2022/01/16 12:31:05     install mono 5.20.1.34-18 End /bin/rm -rf /var/packages/mono/WIZARD_UIFILES ret=[0]
2022/01/16 12:31:05     install mono 5.20.1.34-18 Begin /bin/mv -f /volume1/@tmp/pkginstall/extract.3keote/WIZARD_UIFILES /var/packages/mono/WIZARD_UIFILES
2022/01/16 12:31:05     install mono 5.20.1.34-18 End /bin/mv -f /volume1/@tmp/pkginstall/extract.3keote/WIZARD_UIFILES /var/packages/mono/WIZARD_UIFILES ret=[0]
2022/01/16 12:31:05     install mono 5.20.1.34-18 Begin /bin/rm -rf /var/packages/mono/conf
2022/01/16 12:31:05     install mono 5.20.1.34-18 End /bin/rm -rf /var/packages/mono/conf ret=[0]
2022/01/16 12:31:05     install mono 5.20.1.34-18 Begin /bin/mv -f /volume1/@tmp/pkginstall/extract.3keote/conf /var/packages/mono/conf
2022/01/16 12:31:05     install mono 5.20.1.34-18 End /bin/mv -f /volume1/@tmp/pkginstall/extract.3keote/conf /var/packages/mono/conf ret=[0]
2022/01/16 12:31:08     install mono 5.20.1.34-18 Begin postinst
2022/01/16 12:31:08     Begin reload_inst_variables
2022/01/16 12:31:08     End reload_inst_variables
2022/01/16 12:31:08     Begin initialize_variables
2022/01/16 12:31:08     End initialize_variables
2022/01/16 12:31:08     ===> Step postinst. USER= GROUP= SHARE_PATH=
2022/01/16 12:31:08     Begin save_wizard_variables
2022/01/16 12:31:08     End save_wizard_variables
2022/01/16 12:31:08     Begin syno_sync_var_folder
2022/01/16 12:31:08     End syno_sync_var_folder
2022/01/16 12:31:08     Begin service_postinst
2022/01/16 12:31:08     Mono Certificate Store Sync - version 5.20.1.34
2022/01/16 12:31:08     Populate Mono certificate store from a concatenated list of certificates.
2022/01/16 12:31:08     Copyright 2002, 2003 Motus Technologies. Copyright 2004-2008 Novell. BSD licensed.
2022/01/16 12:31:08     Importing into legacy user store:
2022/01/16 12:31:08     I already trust 0, your new list has 138
2022/01/16 12:31:08     Certificate added: CN=ACCVRAIZ1, OU=PKIACCV, O=ACCV, C=ES
...                     ...
2022/01/16 12:31:09     Certificate added: C=US, O="thawte, Inc.", OU=Certification Services Division, OU="(c) 2008 thawte, Inc. - For authorized use only", CN=thawte Primary Root CA - G3
2022/01/16 12:31:09     138 new root certificates were added to your trust store.
2022/01/16 12:31:09     Import process completed.
2022/01/16 12:31:09     End service_postinst
2022/01/16 12:31:09     install mono 5.20.1.34-18 End postinst ret=[0]
2022/01/16 12:31:09     install mono 5.20.1.34-18 Begin start-stop-status start
2022/01/16 12:31:09     install mono 5.20.1.34-18 End start-stop-status start ret=[0]

Copy link
Contributor

@hgy59 hgy59 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
don't forget to update SPK_REV

@publicarray
Copy link
Member Author

Thanks but how on application launch (e.g. sonarr) can we tell the mono where to find the new tls store? http://docs.go-mono.com/?link=man%3Amono(1)

@publicarray
Copy link
Member Author

Alternatively every mono app needs to do this and store a copy because it's now using the home/user directory

@bakerboy448
Copy link

bakerboy448 commented Jan 16, 2022

Thanks but how on application launch (e.g. sonarr) can we tell the mono where to find the new tls store? http://docs.go-mono.com/?link=man%3Amono(1)

you shouldn't need to should you?

the fix that has been working is sudo /var/packages/mono/target/bin/cert-sync /etc/ssl/certs/ca-certificates.crt which this appears to do?

it'd be nice to get this merged and pushed so it stops the deluge of support requests and thousands of users with broken NASes due to the bug.

@publicarray
Copy link
Member Author

publicarray commented Jan 16, 2022

No unfortunately sudo is no longer available for packages in DSM7

On top of that the default path Access to the path "/usr/share/.mono" is denied.

And needs root access so in this PR the path for DSM7 is changed to /var/packages/mono/var/.mono

The 2nd part that is missing is to tell sonarr aka mono on launch about it hence why it is WIP.

@@ -26,6 +26,7 @@ CONFIGURE_ARGS = --disable-mcs-build
CONFIGURE_ARGS += --enable-btls
CONFIGURE_ARGS += --disable-dependency-tracking
CONFIGURE_ARGS += --without-mcs-docs
CONFIGURE_ARGS += --prefix=$(INSTALL_PREFIX)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not required as already added with GNU_CONFIGURE = 1

Suggested change
CONFIGURE_ARGS += --prefix=$(INSTALL_PREFIX)

@Stanzilla
Copy link
Contributor

Any chance to get this shipped soon?

@publicarray
Copy link
Member Author

publicarray commented Apr 20, 2022

Any chance to get this shipped soon?

No idea, did you test if it works? I would need to test this on an untouched DSM or reinstall one because I think I modified my /usr/share/.mono some time ago on my virtual DSM. No point shipping something that isn't proven to fix the issue.

@Stanzilla
Copy link
Contributor

Any chance to get this shipped soon?

No idea, did you test if it works? I would need to test this on an untouched DSM or reinstall one because I think I modified my /usr/share/.mono some time ago on my virtual DSM. No point shipping something that isn't proven to fix the issue.

Ah sorry, I missed the fact that the CI uploads artifacts, I tested it and Sonarr still has the connection errors do I need an updated Sonarr package to test this as well?

@manubell
Copy link

manubell commented Apr 21, 2022

Just did a test and did not seem to work for me.

My system setup:
NAS Model: DS218+
NAS Architecture: INTEL Celeron J3355
DSM version: DSM 7.0.1-42218

Steps exectuted:
Reproduce error

  1. Installed Sonarr + Mono from package center -> Errors occur
  2. Uninstalled Sonarr + uninstalled Mono

observe PR package
3. Installed mono_x64-7.0_5.20.1.34-18.spk from PR
4. Installed Sonarr -> Errors still occur

Sonarr logs example of 1 of the errors

System.Net.WebException: Error: TrustFailure (Authentication failed, see inner exception.): 'https://services.sonarr.tv/v1/time' ---> System.Net.WebException: Error: TrustFailure (Authentication failed, see inner exception.) ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> Mono.Btls.MonoBtlsException: Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED
  at /github/workspace/spk/mono/work-x64-7.0/mono-5.20.1.34/external/boringssl/ssl/handshake_client.c:1132
  at Mono.Btls.MonoBtlsContext.ProcessHandshake () [0x00038] in <effa5e2bda7548298f9faf7a677f5981>:0 
  at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status, System.Boolean renegotiate) [0x000a1] in <effa5e2bda7548298f9faf7a677f5981>:0 
  at (wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake(Mono.Net.Security.AsyncOperationStatus,bool)
  at Mono.Net.Security.AsyncHandshakeRequest.Run (Mono.Net.Security.AsyncOperationStatus status) [0x00006] in <effa5e2bda7548298f9faf7a677f5981>:0 
  at Mono.Net.Security.AsyncProtocolRequest.ProcessOperation (System.Threading.CancellationToken cancellationToken) [0x000ff] in <effa5e2bda7548298f9faf7a677f5981>:0 
  at Mono.Net.Security.AsyncProtocolRequest.StartOperation (System.Threading.CancellationToken cancellationToken) [0x0008b] in <effa5e2bda7548298f9faf7a677f5981>:0 
   --- End of inner exception stack trace --

/var/log/packages/mono.log (this log is only the PR package installation)

2022/04/22 00:59:34     install mono 5.20.1.34-18 Begin preinst
2022/04/22 00:59:34     Begin reload_inst_variables
2022/04/22 00:59:34     End reload_inst_variables
2022/04/22 00:59:34     Begin initialize_variables
2022/04/22 00:59:34     End initialize_variables
2022/04/22 00:59:34     ===> Step preinst. USER= GROUP= SHARE_PATH=
2022/04/22 00:59:34     install mono 5.20.1.34-18 End preinst ret=[0]
2022/04/22 00:59:34     install mono 5.20.1.34-18 Begin /bin/mkdir -p /volume1/@appstore/mono
2022/04/22 00:59:34     install mono 5.20.1.34-18 End /bin/mkdir -p /volume1/@appstore/mono ret=[0]
2022/04/22 00:59:34     install mono 5.20.1.34-18 Begin /bin/rm -rf /volume1/@appstore/mono
2022/04/22 00:59:34     install mono 5.20.1.34-18 End /bin/rm -rf /volume1/@appstore/mono ret=[0]
2022/04/22 00:59:34     install mono 5.20.1.34-18 Begin /bin/mv -f /volume1/@tmp/pkginstall/extract.jYGNGx/package /volume1/@appstore/mono
2022/04/22 00:59:34     install mono 5.20.1.34-18 End /bin/mv -f /volume1/@tmp/pkginstall/extract.jYGNGx/package /volume1/@appstore/mono ret=[0]
2022/04/22 00:59:34     install mono 5.20.1.34-18 Begin /bin/rm -rf /var/packages/mono
2022/04/22 00:59:35     install mono 5.20.1.34-18 End /bin/rm -rf /var/packages/mono ret=[0]
2022/04/22 00:59:35     install mono 5.20.1.34-18 Begin /bin/mkdir -p /var/packages/mono
2022/04/22 00:59:35     install mono 5.20.1.34-18 End /bin/mkdir -p /var/packages/mono ret=[0]
2022/04/22 00:59:35     install mono 5.20.1.34-18 Begin /bin/touch /var/packages/mono/installing
2022/04/22 00:59:35     install mono 5.20.1.34-18 End /bin/touch /var/packages/mono/installing ret=[0]
2022/04/22 00:59:35     install mono 5.20.1.34-18 Begin /bin/mv -f /volume1/@tmp/pkginstall/extract.jYGNGx/INFO /var/packages/mono/INFO
2022/04/22 00:59:35     install mono 5.20.1.34-18 End /bin/mv -f /volume1/@tmp/pkginstall/extract.jYGNGx/INFO /var/packages/mono/INFO ret=[0]
2022/04/22 00:59:35     install mono 5.20.1.34-18 Begin /bin/rm -rf /var/packages/mono/scripts
2022/04/22 00:59:35     install mono 5.20.1.34-18 End /bin/rm -rf /var/packages/mono/scripts ret=[0]
2022/04/22 00:59:35     install mono 5.20.1.34-18 Begin /bin/mv -f /volume1/@tmp/pkginstall/extract.jYGNGx/scripts /var/packages/mono/scripts
2022/04/22 00:59:35     install mono 5.20.1.34-18 End /bin/mv -f /volume1/@tmp/pkginstall/extract.jYGNGx/scripts /var/packages/mono/scripts ret=[0]
2022/04/22 00:59:35     install mono 5.20.1.34-18 Begin /bin/rm -rf /var/packages/mono/WIZARD_UIFILES
2022/04/22 00:59:35     install mono 5.20.1.34-18 End /bin/rm -rf /var/packages/mono/WIZARD_UIFILES ret=[0]
2022/04/22 00:59:35     install mono 5.20.1.34-18 Begin /bin/mv -f /volume1/@tmp/pkginstall/extract.jYGNGx/WIZARD_UIFILES /var/packages/mono/WIZARD_UIFILES
2022/04/22 00:59:35     install mono 5.20.1.34-18 End /bin/mv -f /volume1/@tmp/pkginstall/extract.jYGNGx/WIZARD_UIFILES /var/packages/mono/WIZARD_UIFILES ret=[0]
2022/04/22 00:59:35     install mono 5.20.1.34-18 Begin /bin/rm -rf /var/packages/mono/conf
2022/04/22 00:59:35     install mono 5.20.1.34-18 End /bin/rm -rf /var/packages/mono/conf ret=[0]
2022/04/22 00:59:35     install mono 5.20.1.34-18 Begin /bin/mv -f /volume1/@tmp/pkginstall/extract.jYGNGx/conf /var/packages/mono/conf
2022/04/22 00:59:35     install mono 5.20.1.34-18 End /bin/mv -f /volume1/@tmp/pkginstall/extract.jYGNGx/conf /var/packages/mono/conf ret=[0]
2022/04/22 00:59:36     install mono 5.20.1.34-18 Begin postinst
2022/04/22 00:59:36     Begin reload_inst_variables
2022/04/22 00:59:36     End reload_inst_variables
2022/04/22 00:59:36     Begin initialize_variables
2022/04/22 00:59:36     End initialize_variables
2022/04/22 00:59:36     ===> Step postinst. USER= GROUP= SHARE_PATH=
2022/04/22 00:59:36     Begin save_wizard_variables
2022/04/22 00:59:36     End save_wizard_variables
2022/04/22 00:59:36     Begin syno_sync_var_folder
2022/04/22 00:59:36     End syno_sync_var_folder
2022/04/22 00:59:36     Begin service_postinst
2022/04/22 00:59:36     /var/packages/mono/scripts/service-setup: line 21: /cert-sync: No such file or directory
2022/04/22 00:59:36     End service_postinst
2022/04/22 00:59:36     install mono 5.20.1.34-18 End postinst ret=[0]
2022/04/22 00:59:36     install mono 5.20.1.34-18 Begin start-stop-status start
2022/04/22 00:59:36     install mono 5.20.1.34-18 End start-stop-status start ret=[0]```

@publicarray
Copy link
Member Author

Thanks for the detailed log and information. Sorry that it doesn't work 😢

@mbnn
Copy link

mbnn commented Jul 14, 2022

Can this be merged pls? :)

@mreid-tt
Copy link
Contributor

hey @publicarray, as #5604 is now merged and published I believe this PR can be closed.

@mreid-tt mreid-tt mentioned this pull request Feb 24, 2023
6 tasks
@mreid-tt
Copy link
Contributor

Closing this PR as it has been superseded by #5604.

@mreid-tt mreid-tt closed this Feb 24, 2023
@publicarray publicarray deleted the fix-tls-mono branch February 24, 2023 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sonarr 3.0.6.1342 - Certificate validation errors after updating to Mono 5.20.1.34-18
7 participants