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

Notify shows messages in the wrong language #2008

Open
thw0rted opened this issue Apr 20, 2020 · 14 comments
Open

Notify shows messages in the wrong language #2008

thw0rted opened this issue Apr 20, 2020 · 14 comments

Comments

@thw0rted
Copy link
Contributor

Problem Description

I recently updated OpenSC using the MSI installer. I think my older version didn't have the notification service, or it wasn't enabled, so I selected the Notify option during install. Today, when I logged in to my computer, the Windows Action Center had two messages from "OpenSC Notify", and both were in German. (I don't remember the exact wording, but something to the effect of "card reader was recognized" and "card is ready".)

As far as I can tell, there is nothing on the wiki about the Notify service, and I don't see any relevant lines in opensc.conf. I actually can't find a binary with notify in the name anywhere in the install directory either?

Proposed Resolution

Notifications should use the OS language (English, in my case) if possible, or fall back to a sensible default (again, English?) if not.

Steps to reproduce

No idea, honestly.

Logs

I don't know where Notify logs would show up, if there are any -- again, I don't see any documentation.

@frankmorgner
Copy link
Member

We are using the following language (in preference order):

  1. Language announced by the card (p15card->tokeninfo->preferred_language)
  2. if on Win32: German if it's returned by GetUserDefaultUILanguage
  3. if on Unix: LANGUAGE if set
  4. English (the default)

    OpenSC/src/ui/strings.c

    Lines 158 to 174 in 5e79a2a

    /* load language */
    /* card's language supersedes system's language */
    if (!p15card || !p15card->tokeninfo
    || !find_lang_str(p15card->tokeninfo->preferred_language, &lang)) {
    #ifdef _WIN32
    LANGID langid = GetUserDefaultUILanguage();
    if ((langid & LANG_GERMAN) == LANG_GERMAN) {
    lang = DE;
    }
    #else
    /* LANGUAGE supersedes locale */
    if (!find_lang_str(getenv("LANGUAGE"), &lang)) {
    /* XXX Should we use LC_MESSAGES instead? */
    find_lang_str(setlocale(LC_ALL, ""), &lang);
    }
    #endif
    }

If you want to disable autostart of opensc-notify.exe, please remove the registry entry HKMU\Software\Microsoft\Windows\CurrentVersion\Run\opensc-notify.exe.

Sorry, for not having a better documentation on that.

@thw0rted
Copy link
Contributor Author

This is strange. Do you happen to know how to check the value being returned by GetUserDefaultUILanguage from an end user perspective, like somewhere in Settings / Control Panel? I do happen to be located in Germany, but this is on a system bought in the US, showing "United States" under Settings -> Region, using "English (United States)" as the Region Format. The card is a US military ID so it would be unlikely to have a German "preferred language" token.

As far as I can tell, I don't have a LANGUAGE or LC_ALL in my environment either.

@frankmorgner
Copy link
Member

Could you check the Advanced tab of the regional and language options portion of Control Panel, see https://docs.microsoft.com/de-de/windows/win32/intl/user-interface-language-management?

@frankmorgner
Copy link
Member

Does pkcs15-tool --list-info show a Language for your card?

@dengert
Copy link
Member

dengert commented Apr 20, 2020

You can also disable OpenSC Notify using Task Manager Startup and disable OpenSC Notify, then Sign out and then Sign in.

@thw0rted
Copy link
Contributor Author

@frankmorgner no, it only shows Version, Serial Number, Manufacturer ID, and Flags (which is empty).

The wording on the Windows documentation page you linked to is confusing, and I think might be out of date since Microsoft has been hard at work breaking everything in Control Panel / Settings for the last few seasonal updates. I do not have an "Advanced tab" in the Region control panel, nor is there anything like "Advanced" under Settings -> Time & Language -> Region. (It has a link for "Additional time, date, & regional settings" but it just opens the Region section of the Control Panel.)

@dengert thank you for the instructions. I'm not too worried about it at the moment, I was just trying to figure out how it settled on choosing German to show the messages.

@dengert
Copy link
Member

dengert commented Apr 20, 2020

Go to search box type Language. It will point you at the language settings

@thw0rted
Copy link
Contributor Author

image

No mention of German, no "Advanced" tab / dialog that I can see. Please let me know if I'm missing anything.

@dengert
Copy link
Member

dengert commented Apr 20, 2020

Sorry. Yours looks like mine. English for both Windows Display Language and Prefered language.
But OpenSC notify shows english.

@thw0rted
Copy link
Contributor Author

Maybe this is a dumb question, but when should I be getting notifications? As I said, I updated the drivers some time ago, and this morning is I think the only time I've ever seen any notifications. Just now, as an experiment, I removed the card from the reader, waited a bit, then re-inserted it, and at no point did I get a notification in the Action Center. Same with unplugging/re-plugging the reader's USB cable.

Maybe my notify is more broken than I thought?

@dengert
Copy link
Member

dengert commented Apr 20, 2020

I can get the German message "Smartcard kann jetzt vervendit" using a NitroKey Pro. The other german made card, a SmartCard-HSM uses English. It only used German for the smart card is ready, after it has read the tokenInfo.

./pkcs15-tool --list-info
Using reader with a card: Nitrokey Nitrokey Pro (0000000000000000000080B8) 00 00
PKCS#15 Card [OpenPGP card]:
	Version        : 0
	Serial number  : 0005000080b8
	Manufacturer ID: ZeitControl
	Language       : de
	Flags          : PRN generation, EID compliant
./pkcs15-tool --list-info
Using reader with a card: SCM Microsystems Inc. SCR 355 [CCID Interface] 00 00
PKCS#15 Card [SmartCard-HSM]:
	Version        : 0
	Serial number  : DECC0100248
	Manufacturer ID: www.CardContact.de
	Flags          : 




@frankmorgner
Copy link
Member

Regarding the events, there was this issue solved recently #1923. PIN verification events should work as expected. Just run certutil -scinfo, for example.

@StephenBentley-ATS
Copy link

Same issue here using CAC (with PIV activated). When I first put in the smartcard I get a "Smart card detected" notification in English. All subsequent notifications are in German. All regional/language settings are, and have always been, English (US).

OpenSC-0.20.0
OS Name: Microsoft Windows 10 Enterprise
OS Version: 10.0.16299 Build 16299
System Manufacturer: Dell Inc.
System Model: Latitude 7480

> ./opensc-tool --list-readers
# Detected readers (pcsc)
Nr.  Card  Features  Name
0    Yes             Broadcom Corp Contacted SmartCard 0
1    Yes             Broadcom Corp Contactless SmartCard 0
2    Yes             SCM Microsystems Inc. SCRx31 USB Smart Card Reader 0

Using external USB card reader

> ./pkcs15-tool --list-info
Using reader with a card: Broadcom Corp Contacted SmartCard 0
Failed to connect to card: Card not present
> ./pkcs11-tool --show-info
Cryptoki version 2.20
Manufacturer     OpenSC Project
Library          OpenSC smartcard framework (ver 0.20)
Using slot 2 with a present token (0x8)

Using integrated card reader

> ./pkcs15-tool --list-info
Using reader with a card: Broadcom Corp Contacted SmartCard 0
PKCS#15 Card [REDACTED]:
        Version        : 0
        Serial number  : REDACTED
        Manufacturer ID: Common Access Card
        Flags          :
> ./pkcs11-tool --show-info
Cryptoki version 2.20
Manufacturer     OpenSC Project
Library          OpenSC smartcard framework (ver 0.20)
Using slot 0 with a present token (0x0)

I have also added card_drivers = cac, cac1, PIV-II, default; to opensc.conf, but this localization issue was presenting before making that change.

@frankmorgner
Copy link
Member

I added some debugging to the code, please check whether strings.c appears in the opensc log with #2984

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants