Search Unity

UWP -> Target Device + Certificate Questions

Discussion in 'Windows' started by PeachyPixels, Jan 8, 2021.

  1. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Hi Everyone,

    I've finally finished my first game and am very close to publishing (initially on the Windows Store)

    The project is configured and ready to deploy, but I have some questions that I'd be grateful if someone could help with please.

    1. What does Target Device actually effect? (on Build Settings -> Universal Windows Platform)

    2. Is it ok to use a password protected self signed certificate or obtain\generate one from 'trusted' source as the MS docs imply...

    https://docs.microsoft.com/en-gb/windows/msix/package/create-certificate-package-signing

    3. If so to 2, I'm guessing I have to regenerate it every year as the expiry date is hard coded?

    4. I've created a 'test' password protected self signed certificate. When sideloading the package, I have to press Y to install the certificate to the Trusted People category. I assume when creating a store package, this is handled seamlessly?

    Sorry for all the certificate questions. I've never had to generate and\or install my own until now, so just want to make sure I'm doing it right.
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Not much. Back when Windows phone was a thing, it was a way to disable Unity from packing assets in a way that couldn't be used on those devices. Currently, it only controls whether "SHADER_API_DESKTOP" define is defined in shaders (it's only defined when the Target Device is set to PC). I suggest just set it to PC and forget about it. We are removing this setting in a subsequent Unity version and making the behaviour be as if it was set to PC.

    As for the certificates: for development, test certificate is ok. At some point during your development, you will have to set up an application on the Windows Store storefront/dashboard. This will create an app identity, alongside a certificate that is provided by Microsoft. When you open a Visual Studio project that got created when you built your game to UWP in Unity, you can do that by "PROJECT" -> "Publish" -> "Reserve App Name...". Then, you can associate the Visual Studio project with that application by doing "PROJECT" -> "Publish" -> "Associate App with the Store...". This will automatically download the correct certificate and make the project use it. Once done and uploaded to the Windows Store, those certificate prompts do not come up.
     
    Chrisdbhr and PeachyPixels like this.
  3. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Great, thanks! That's exactly what I did as assumed Mobile was Windows Phone (which I'm obviously not targeting)

    So a rookie question :) Sorry about that, but thanks again, that makes perfect sense. I created the developer account some weeks back and hadn't got around to setting it up yet.
     
  4. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Hi Everyone,

    I'm having a UWP certificate issue and to be honest, not exactly sure where the problem lies, so thought I would start at the source and work forwards.

    So I've created a UWP Test Certificate (in Unity) and configured the publisher name like so...

    MyGamesCompany

    If I then generate a UWP build (and before associating with the app store) the app manifest shows the packaging publisher as...

    CN=MyGamesCompany

    After associating with the app store, the app manifest shows the packaging publisher as...

    CN=A1B2C3D4-A1B2-A1B2-A1B2-A1B2C3D4E5F6

    This was working for a while, but something has changed recently and I now receive the following error (upon submitting the package to the app store)...

    Invalid package publisher name: CN=A1B2C3D4-A1B2-A1B2-A1B2-A1B2C3D4E5F6 (expected: CN=MyGamesCompany)

    Looking at the Unity UWP build page, the example given uses the publisher name not the id...

    https://docs.unity3d.com/Manual/class-PlayerSettingsWSA.html

    And this article shows the same approach...

    https://www.stingbotgames.com/singl...ting-a-game-for-windows-uwp-in-unity-3d-2017x

    (although both are outdated now)

    I understand MS will generate a certificate for the app to use (which you would assume would be CN=A1B2C3D4-A1B2-A1B2-A1B2-A1B2C3D4E5F6) but the only one available to associate in Visual Studio shows the publisher as CN=MyGamesCompany

    Which generates the same problem!

    So no matter how I configure things (publisher name & id etc) none seem to work.

    I'd be very interested to hear how others have their apps configured and what this could possibly be.

    Any help would be greatly appreciated.
     
  5. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    To clarify my comment on using the certificate that Visual Studio presents (post associate app with store)

    In that instance, the packaging publisher shows as...

    CN=MyGamesCompany

    But when I submit to the store, I now see the error...

    Invalid package publisher name: CN=MyGamesCompany (expected: CN=A1B2C3D4-A1B2-A1B2-A1B2-A1B2C3D4E5F6)

    So as you see, it fails either way around.
     
  6. rab

    rab

    Joined:
    Nov 13, 2009
    Posts:
    101
    Hi,

    have the same problem. Visual Studio replaces the publisher name when creating the packages:

    See the log when bulding
    • 2>C:\Program Files (x86)\Microsoft Visual Studio\[...]AppxPackage\Microsoft.AppXPackage.Targets(2698,5): warning : Der Herausgebername (CN=7426DF4B-7686-414E-8A6A-DE1246D2B34E) stimmt nicht mit dem Signaturzertifikataussteller überein: CN=RAB-Software. Der Herausgebername wird aktualisiert.
    saying that the publisher name is different to the signature creator so the publisher name will be updated.

    This seems to be the problem. Any idea how to solve this?

    Kind regards!
     
  7. rab

    rab

    Joined:
    Nov 13, 2009
    Posts:
    101
    Hello again,

    there is still no way of getting an package to the Microsoft store due to the signature problem. It seems that the user created test certificate is used when building the upload package and not the certificate from the store (what you get when you assign the app to the store entry).

    Is this a Unity-Bug, doing something wrong on building the Visual Studio files or is it a problem which needs Microsoft to solve within Visual Studio?

    Last try on Visual Studio 16.10 fails.

    Kind regards.
     
  8. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Hi @Tautvydas-Zilys,

    I've reported this to Microsoft and a few others (who also appear to use Unity) have replied that they are experiencing the same issue. But there is no resolution and MS have stopped replying.

    The MS support agent claims the relevant certificate is generated during the Associate with App Store process. But this clearly isn't happening.

    Could this be a Unity issue where the VS project is not configured correctly? (as a result, the certificate is not generated when it should be)

    Any help would be appreciated as right now it appears the Unity self-signed certificate is being used in production uploads, which is obviously far from ideal.
     
  9. rab

    rab

    Joined:
    Nov 13, 2009
    Posts:
    101
    Hi,

    just tried Visual Studio 16.10.1 Update. Problem stays the same.

    Kind regards.
     
    PeachyPixels likes this.
  10. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Hi @rab

    Thanks for the update.

    I think that's you replying in the thread I posted on the Microsoft site as well?

    I'm working on the iOS build at the moment, but will be back to Windows soon hopefully.

    I'll keep pushing this though as there is definitely something not right here. Just not sure if it's a Unity or Microsoft issue.
     
    rab likes this.
  11. rab

    rab

    Joined:
    Nov 13, 2009
    Posts:
    101
    Hi @PeachyPixels,

    you are right - the same guy looking for a bug fix at MS ...

    I try to bring my GlobeViewer Apps to MS Store but this seems to be impossible right now. Did you file an Unity bug already? May be this speeds up things when Unity realizes that one platform can't be reached now? Would be helpful to know that the error is in Visual Studio not at the Unity side...

    Kind regards!
     
  12. rab

    rab

    Joined:
    Nov 13, 2009
    Posts:
    101
    Hi,

    Visual Studio 16.10.2 update has also no effect on this problem.

    Posting an Unity Bug report... Case 1343559

    May be this will speed up things.

    Kind regards.
     
    Last edited: Jun 16, 2021
  13. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Hi everyone, just got back from vacation. We will take a look.

    One way to see if this is a Unity specific issue would be to create an empty C++ UWP project from Visual Studio (that has nothing do to with Unity) and try seeing if you can get past this error with that.
     
  14. rab

    rab

    Joined:
    Nov 13, 2009
    Posts:
    101
    Hi @Tautvydas-Zilys,

    just updated the bug report (Case 1343559) with steps to reproduce the problem.

    Edit: Link to Bugreport added.

    Kind regards.
     
    Last edited: Jun 23, 2021
    PeachyPixels likes this.
  15. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Many thanks for submitting the bug report @rab

    Let's hope it's an easy & quick fix.
     
  16. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Hi, just wanted to update this thread. Something definitely goes wrong with app store association - I can reproduce this issue as well. I'm first and foremost trying to find a workaround so that everyone who is running into this is unblocked. I'll post again when I have one :).
     
  17. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Okay, here's the workaround:

    1. Associate the app with the store as usual;
    2. In Visual Studio solution explorer, right click on "Package.appxmanifest", press "Open with...": upload_2021-6-30_14-27-47.png
    3. Select XML (Text) Editor, press OK: upload_2021-6-30_14-27-26.png
    4. Copy the publisher identity GUID (circled in red): upload_2021-6-30_14-29-41.png
    5. Close the manifest, and double click it to reopen it in the visual designer UI. Go to the packing tab and press "Choose Certificate...": upload_2021-6-30_14-31-41.png

    6. Press the "Create..." button: upload_2021-6-30_14-32-5.png
     
  18. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    (continued)

    7. Replace "Publisher Common Name" with the GUID you copied in step 4, press OK (you can leave the password fields blank):
    upload_2021-6-30_14-33-47.png

    That's it. I am still investigating the root cause of this, but after doing this, you should be able to submit to the Windows Store.
     
    rab and PeachyPixels like this.
  19. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Many thanks @Tautvydas-Zilys that's very helpful.

    I'll try it in the next few days and will report back my findings.
     
  20. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    BTW the test app I submitted to the Windows Store yesterday got approved over night, so this workaround should definitely work :).
     
    PeachyPixels likes this.
  21. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    PeachyPixels likes this.
  22. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Agreed. I have vague recollections of the issue appearing after a 2019 update. But I was in the early days of my first store submission, so wasn't sure if it was me or not.

    I only posted on here because I wasn't sure if the Unity generated project(s) were incorrectly configured, causing issues further down the line.

    I've tried reporting this to MS (as has @rab) but so far, it's mostly just silence. Hopefully you will have more success. I will certainly be keeping an eye on it.

    Thank you so much for all your efforts with this so far, it's greatly appreciated :)
     
    rab likes this.
  23. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    PS: It's been broken for quite a number of months, so an earlier 2019 version for sure.
     
  24. rab

    rab

    Joined:
    Nov 13, 2009
    Posts:
    101
    Thank you @Tautvydas-Zilys!

    Will check it out later with my project. Good to have a workaround.

    Edit: Ok, workaround is working. Thank you!

    Kind regards!
     
    Last edited: Jul 16, 2021
  25. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
  26. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
  27. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Hi @Tautvydas-Zilys

    So I've just built the store packages using the fixed VS version (16.11.1) and these are my findings associating the app with the store...

    1) I am seeing the new attribute that MS have added in the VCXPROJ file...

    <PropertyGroup>
    <GenerateTemporaryStoreCertificate>True</GenerateTemporaryStoreCertificate>
    <AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
    </PropertyGroup>

    2) I was able to select a certificate from the store, which I was unable to-do before. It contained my publisher name (without CN=) but was only valid for one year (from the date it was created a few months ago) and still appears to be the self signed version.

    3) I still see the WSATestCertificate.pfx file in the project and it's referenced in the VCXPROJ file, but only in <ItemGroup>

    The packages uploaded to the store submission and were verified, but I'm unsure if the test certificate is still being used or not.

    As per the MS thread, should I really have created a new certificate in VS during app associated? All that seems to-do is create another self-signed certificate.

    Do MS generate a non self-signed certificate on store upload?
     
    Last edited: Aug 19, 2021
  28. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Correct, Microsoft will generate the final certificate at submission time on their end and replace the self signed certificate. You're not expected to generate anything yourself.
     
    PeachyPixels likes this.
  29. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Great! Thanks for confirming and thanks again for working with MS on this issue :)