Page MenuHomePhabricator

CERTIFICATE_VERIFY_FAILED error when trying to access Wikipedia API with Mono
Closed, ResolvedPublicBUG REPORT

Assigned To
Authored By
Vort
Nov 6 2021, 9:27 AM
Referenced Files
F41510918: image.png
Nov 16 2023, 2:11 PM
F34734267: WikiTLSTest.exe
Nov 6 2021, 9:27 AM
F34734270: err.txt
Nov 6 2021, 9:27 AM

Description

When I try to make Wikipedia connection with Mono from my Toolforge tool account wikitasks, error appears.

To help with bughunting, I made test program, which should return MediaWiki version in case of success and error otherwise.

Here is the source code:

using System;
using System.Net;
using System.Xml;

namespace WikiTLSTest
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine($"WikiTLSTest check is started.");
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            var wc = new WebClient();
            wc.Headers.Add("User-Agent", "WikiTLSTest");

            var xml = wc.DownloadString(
                "https://ru.wikipedia.org/w/api.php" +
                "?action=query&format=xml&meta=siteinfo");

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);

            var generalNode = doc.SelectSingleNode("/api/query/general");

            Console.WriteLine($"WikiTLSTest result: {generalNode.Attributes["generator"].Value}");
        }
    }
}

And here is binary, which should be executed with mono WikiTLSTest.exe command:

Please run this program from old enough tool account (< 1 Oct 2021) and if you see no error

, then let me know about it.
If you see error, then, please reopen T292289 and make proper fix for it.

Event Timeline

I ran the provided test case and it seems to be working:

:# on the bastion
tools.taavi-test-tool@tools-sgebastion-11:~$ mono T295220/WikiTLSTest.exe
WikiTLSTest check is started.
WikiTLSTest result: MediaWiki 1.42.0-wmf.4

:# using the jobs framework
tools.taavi-test-tool@tools-sgebastion-11:~$ toolforge jobs run --image mono6.8 --command "mono T295220/WikiTLSTest.exe" wikitlstest --wait
INFO: job 'wikitlstest' completed
tools.taavi-test-tool@tools-sgebastion-11:~$ cat wikitlstest.*
WikiTLSTest check is started.
WikiTLSTest result: MediaWiki 1.42.0-wmf.4

I believe this was fixed with @bd808's https://gerrit.wikimedia.org/r/c/operations/docker-images/toollabs-images/+/844512/ last year.

@taavi how to apply this fix to my Toolforge account?
I probably have some old data stuck somewhere.
This is what I'm getting right now:

image.png (984×1 px, 133 KB)

I deleted some Mono certificate cache directories from your tool's home directory:

tools.wikitasks@tools-sgebastion-10:~$ rm -rf .config/.mono/certs .config/.mono/new-certs/

and now it seems to work fine:

tools.wikitasks@tools-sgebastion-10:~$ mono WikiTLSTest.exe
WikiTLSTest check is started.
WikiTLSTest result: MediaWiki 1.42.0-wmf.4
Vort claimed this task.

Thank you.
I will proceed with learning of how to migrate my tools next.