How to strong sign an .exe file in .NET? - asp.net

how to properly sign an .exe with a pfx certificate installed on machine.
I have a pfx certificate by the name "Services installed. I tried signing the exe with this command.
.\sn.exe -Rc "%Directory%\File.exe" "Services" >> "%LogPath%"
It gave no errors. But when I ran this exe file, it started throwing error for the internal project dll(ExtraFile.dll), which is referenced inside File.exe project.
This dll I am already signing before signing the File.exe file. So the signing steps are as follow.
.\sn.exe -Rc "%Directory%\ExtraFile.dll" "Services" >> "%LogPath%"
.\sn.exe -Rc "%Directory%\File.exe" "Services" >> "%LogPath%"
Please note that ExtraFile.dll is referenced under File.exe project.

Creating a cryptographic key pair using the Strong Name tool (Sn.exe) and assigning that key pair to the assembly using either a command-line compiler or the Assembly Linker (Al.exe). The Windows SDK provides both Sn.exe and Al.exe.

Related

getting No certificate found with the supplied thumbprint error in Xamarin project

I am creating a pipeline to Build a XAMARIN project.
The project compiles on my desktop but I am having trouble compiling it in classic DevOps. The project is under Team Foundation Version Control Repos.
I have followed the example in this link: https://yanxiaodi.medium.com/using-azure-devops-build-pipeline-for-xamarin-forms-436ddc6bcf97
I added the pfx file (created today, expires in a year) to the library Secure files and the pipeline successfully downloads the file. It seems to copy the file to right place because i do not get an error the file is missing. However, I do get the error shown below.
The thumbprint shown is the one that is in the secure file.
what am i doing wrong?
##[error]C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VisualStudio\v17.0\AppxPackage\Microsoft.AppXPackage.Targets(854,5): Error : No certificate found with the supplied thumbprint: 738D7BBE2C2D55EA43D65CA94224E76296C10F1
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VisualStudio\v17.0\AppxPackage\Microsoft.AppXPackage.Targets(854,5): error : No certificate found with the supplied thumbprint: 738D7BBE2C2D55EA943D65CA4224E76296C10F1 [D:\a\9\s\App1.UWP\MyProgram.UWP.csproj]

Password decryption not supported on .NET Core for Windows?

I recently converted a private NuGet repository to require authentication.
To build a project that uses that repository, I added the authentication to the local NuGet.Config with NuGet Sources add -name [repo_name] -Source [source_url] -UserName [username] -Password [password].
I now get the following error when I try running dotnet restore:
Password decryption is not supported on .NET Core for this platform. The following feed uses an encrypted password: 'nuget-sdet'. You can use a clear text password as a workaround.
I know that this isn't supported on linux, but I'm running this on Windows Server 2012 R2.
This is running on a very old version of .NET Core: 1.0.0-preview2-003121.
Is password decryption supported on Windows for newer versions of .NET Core?
Or am I stuck between either storing the password in clear text or re-enabling anonymous access to the feed?
In non windows OS you should add the suffix of --store-password-in-clear-text
to your add command.
As specified in the dotnet nuget add source article here
--store-password-in-clear-text
Enables storing portable package source credentials by disabling password encryption.
I have just came across to this issue on VS for Mac. Answers here are not really enlightening and microsoft documentation is unclear. The name --store-password-in-clear-text sounds like you have to store your repository password. Actually you can simply use an access token instead of your username.
For example on Azure Devops, you go to right-upper corner your account icon as in the image and select "Personal access tokens"
Then create a new access token by giving the permission Packing read
Copy your newly created access token use the command below using from the VS menu Tools->SDK Command Prompt
dotnet nuget add source https://myfeed/nuget/v3/index.json -n myFeed
-u usernamenotimportant -p yourtokencomeshere --store-password-in-clear-text
This command will update your nuget.config file which is found on the path ~/.nuget/Nuget/Nuget.config this path is important because this is the Nuget.Config file used and displayed by Nuget package manager in VS4Mac.
As mentioned here on the MS docu, other path there is the 2nd Nuget.Config ~/.config/NuGet/NuGet.Config that is not displayed by the Package Manager, i think that it is still used by MsBuild but not displayed. it will probably still work but can cause confusion as the Package Manager doesn't show your nuget source and your private packages.
Last point is, dont use Nuget CLI to add the source which is similar command like below
nuget add source https://myfeed/nuget/v3/index.json -name myFeed
-username usernamenotimportant -password yourtokencomeshere -StorePasswordInClearText
This command is updating the other Nuget.Config on the .config folder that wont be displayed by the VS for Mac.
So at the end only your Token is stored like below
<packageSourceCredentials>
<myFeed>
<add key="Username" value="myusername" />
<add key="ClearTextPassword" value="mytokencomeshere" />
</myFeed>
</packageSourceCredentials>

"Illegal characters in path" error when building UWP project with SQLite extension on VSTS Hosted agent

When using a Hosted agent to build my UWP application on VSTS I'm getting an error:
_GenerateAppxSymbolPackage:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\PDBCopy.exe C:\a\1\s\App\MyApp\bin\ARM\Debug\MyApp.pdb obj\ARM\Debug\Stripped\MyApp.pdb
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\PDBCopy.exe C:\a\1\s\App\Extensions\UAP\v0.8.0.0\ExtensionSDKs\SQLite.UWP.2015\3.11.1\Redist\Debug\ARM\sqlite3.pdb obj\ARM\Debug\Stripped\sqlite3.pdb
##[error]C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(2550,5): Error APPX0002: Task 'GenerateAppxSymbolPackage' failed. Illegal characters in path.
My build definition runs for app solution file against VS15 with params:
/p:AppxBundlePlatforms="$(BuildPlatform)" /p:AppxPackageDir="$(Build.BinariesDirectory)\AppxPackages\" /p:AppxBundle=Always /p:UapAppxPackageBuildMode=CI
Everything else is default UWP build definition configuration on VSTS.
Note: my CI build for the same project builds successfully. The only difference there is the lack of /p:UapAppxPackageBuildMode=CI flag.
Any ideas / hints on what might be wrong with those paths? Or is it some bug in VSTS?
The MSBuild Arguments should be like:
/p:AppxBundlePlatforms="$(BuildPlatform)" /p:AppxPackageDir="$(Build.BinariesDirectory)\AppxPackages\\" /p:AppxBundle=Always
There is a \\ after AppxPackages, not \ .
Deleting everything except .git folder and then doing hard reset helped.

Can NativeProcess.isSupported and Updater.isSupported both be true in an AIR application?

I'm trying to check user domain name in Windows, and need native process support.
In the application config xml (xmlns="http://ns.adobe.com/air/application/2.6") I have
<supportedProfiles>extendedDesktop desktop</supportedProfiles>
When I run the application with adl everything works, but when I trying to installing the application (*.air package), I get an error that native proccess is not supported. Interesting that when I install the compiled *.exe file, after installation I have native processes support.
But with *.exe installation I have Updater.isSupported == false, but, when I'm installing with *.air package I have Updater.isSupported == true.
Looks like when I'm installing *.exe I have profile=extendedDesktop, but when I'm using *.air installation package I have using profile=desktop.
But I need both. Is there any way to solve this problem?
compilation:
echo Creating air application
call g:\flex_sdk\bin\adt.bat -package -storetype pkcs12 -keystore mykey.p12 -storepass simple -tsa none news.air news-app.xml .
echo Compile exe
call g:\flex_sdk\bin\adt.bat -package -target native news.exe news.air
What you are asking for is not possible. ApplicationUpdater provided by Adobe does not work with native-code applications.
(You can see the code if you'd like more information on why; it is available in your sdk directory under \frameworks\projects\air\ApplicationUpdater\src.)
However, it is possible to automatically update native-code packaged applications in a similar, though not completely identical, way. See this post on Adobe's website for more information: http://www.adobe.com/devnet/air/articles/updating-air-apps-native-installer.html. I would provide the information here, but I am not the author of that article.

Consuming HTTPS Webservice in Flex 4

I'm trying to consume one HTTPS webservice in Adobe Flash Builder.
when I add the URL I get this error:
There was an error during service
introspection. WSDLException:
faultCode=OTHER_ERROR: Unable to
resolve imported document at
'https://172.21.17.235:9443/testehttpsWeb/sca/testeIOExport1/WEB-INF/wsdl/testehttps_testeIOExport1.wsdl'.:
javax.net.ssl.SSLHandshakeException:
sun.security.validator.ValidatorException:
PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException:
unable to find valid certification
path to requested target
How can I configure my client to consume the Webservice?
We will have to buy ice cream to the person that figured this out!
The solution was to import the certificate not to a JKS truststore, but to the cacarets file, in my case:
keytool -import -alias trusted1 -keystore "C:\Program Files (x86)\Adobe\Adobe Flash Builder 4\jre\lib\security\cacerts" -file c:\somepath\mycert.cer
In this case there is no need to add the:
-Djavax.net.ssl.trustStore="c:\somepath\truststore.jks"
...line on FlashBuilder.ini
An imported note is that the DNS Server must be able to translate the Web Service path by name instead of by IP, because in the installed certificate the CN mentions the Web Service server name not it's IP
Regards
Flash Builder is built on top of Eclipse. Eclipse is written in Java, and this is probably the cause of your issue. Java itself doesn't trust any SSL (it doesn't support the root CAs out of the box, nor any certificates). You have to setup a truststore to use SSL with Java.
In eclipse, this means setting up a truststore and adding it's location to the eclipse.ini. To setup the truststore, first browse in your browser to the SSL site you are connecting to, and save the certificate (usually right/left click on the lock icon and follow the steps). The you need to use "keytool" from the Java JDK to create the truststore, such as:
keytool -import -alias trusted1 -keystore c:\somepath\truststore.jks -file c:\somepath\mycert.cer
Then find your eclipse.ini (usually in your Flex Builder or eclipse folder). Add this:
-Djavax.net.ssl.trustStore="c:\somepath\truststore.jks"

Resources