Category Archives: Windows

Managing SSL for Jenkins with Sectigo Certificates

At VMSoft, I manage a Jenkins instance that uses SSL. To configure SSL using a certificate issued by Sectigo (in my case), the supplied .crt and .key files must be imported into a keystore, which is then passed as a Jenkins startup parameter.

The process of creating a keystore from the .crt and .key files involves using the openssl command-line utility to create a PKCS#12 file:

openssl pkcs12 -export -in <file_name>.crt -inkey <file_name>.key -out jenkins.p12

Next, convert the resulting .p12 file to a .jks file using the keytool utility, which comes bundled with the JDK:

keytool -importkeystore -srckeystore jenkins.p12 -srcstoretype PKCS12 -destkeystore jenkins.jks -deststoretype JKS

Finally, make Jenkins aware that you want to use HTTPS by editing the jenkins.xml configuration file. Modify the jenkins.war command-line arguments by appending the following:

--httpPort=-1 --httpsPort=8443 --httpsKeyStore=<path_to_key_store_file> --httpsKeyStorePassword=<key_store_password>

Note: If your Jenkins instance fails to start, check the error log. If you see an error like:

java.security.UnrecoverableKeyException: Cannot recover key

ensure that the password you provided during the creation of both the PKCS#12 file and the .jks file is the same. Inconsistent passwords can cause this error.

Automating Google Play Store reports with ‘gsutil’ and Windows PowerShell

Why (feel free to skip)

As Android developer I have various mobile devices (phones, tablets, watches) with all Android version starting 4.0 (Ice Cream Sandwich, API 14) up to Android 12 (L, API 31). Those devices accompanied by very detailed test scenarios help me ensure best possible user experience 🙂

Android test devices

As Android developer I have various mobile devices (phones, tablets, watches) with all Android version starting 4.0 (Ice Cream Sandwich, API 14) up to Android 12 (L, API 31).

When prepping release for an app, all test cases for that particular app are performed on each device. For each Android version I keep track of active installs and user rating. Applying that data in the test scenario. This helps me focus more on particular set of for ex. unhappy users running specific OS version.

Below is a screenshot of a test scenario for one of my apps: GSM Signal Monitor & SIM Card Info.

GSM Signal Monitor & SIM Card Info test scenario

GSM Signal Monitor & SIM Card Info test scenario

Each Android version has number of active installs and rating. Going to Google Play Store dev console and collecting this information by hand is somehow tedious job, so I decided to automate it using ‘Google Cloud Storage Util‘ and a bit of Windows PowerShell scripting.

How

Our task is to fetch Google Play store monthly reports for app installs and ratings by OS version, filter them and get data that can easily be copy pasted in the ‘Active Installs‘ tab of the test scenario.

1. Cloud Storage bucket ID

Google Play reports, beside dev console can also be accessed via Google Cloud Storage bucket associated with your developer account. You can go to “Download reports”, pick the report type you want and select “Copy Cloud Storage URI” next to it.

Google Play Cloud Storage URI

The url will look like this

gs://< bucket_id >/stats/installs/

where < bucket_id > will be your actual developer account cloud storage bucket. Remember this bucket id. We will be using it later.

2. Install gsutil

Google provides GSUtil for using cloud storage from the command line. Head over to https://cloud.google.com/storage/docs/gsutil_install#expandable-1 and follow the installation instructions.

We will be utilizing the gsutil.cmd assuming that the script is available in system PATH.

Next we need to authorize gsutil to access our cloud storage data. Follow the instructions on how to Authenticate stand-alone gsutil. For ‘project-id’ use the project ID of the app you want to get reports for. I’m interested in retrieving reports for GSM Signal Monitor & SIM Card Info app so I will be using it’s Cloud Storage project id.

Cloud Storage Project ID

If everything is setup correctly, opening command prompt and typing “gsutil help” should produce result similar to the screenshot below:

gsutil help command output

3. PowerShell magic 🙂

Script below will fetch installs and ratings reports from Google Play for specific app for the current month. Will get the last date available in the install report, filter both install and rating reports by ‘last available date’ and strip the reports from rows / columns we are not interested in. It will iterate over the active installs and will try to match installs with the ratings.

Replace $bucketId and $appPackageName with your cloud storage bucket id and your app package name.

Reports fetched from Google Play and the final output will be saved in the current working directory.

Upon execution you will get a report for your app active users/ratings by Android version, based on the data for the last date available in the install report nicely opened in your default text editor.

Script output: Active users and ratings.

P.S: Enable column selection mode in Notepad++ to get only the numbers. Use the arrow keys or your mouse while holding Shift + Alt.

P.S1: More info on how to retrieve various reports with gsutil here.

Feel free to modify the script to suit your reporting needs 🙂

Git checkouts fail on Windows with “Filename too long error: unable to create file”

Cause

According to the msysgit wiki on GitHub and the related fix this error, Filename too long, comes from a Windows API limitation of file paths having 260 characters or fewer.

Resolution

To resolve this issue, run the following command from GitBash or the Git CMD prompt (as administrator):

git config --system core.longpaths true

This will allow file paths of 4096 characters.

Copying Cyrillic URLs in Google Chrome and Firefox

Using Google Chrome, I encountered strange bug affecting the copying and pasting of cyrillic urls.

When pasting, the non ASCII characters in the Url are converted to Punycode.

Performing some tests revealed that the same behaviour is present also in Firefox.

Punycode produced by Google Chrome and Firefox

Punycode produced by Google Chrome and Firefox

Doing some research led me to Issue 68718, unfortunately marked as WontFix stating:

Links on Wikipedia itself are a red herring, as comment 50 notes -- they're escaped in the page source.  The actual issue here is demonstrated by the link in comment 0.  We escape URLs when copying them.  This behavior matches Firefox 4 (by default) and Safari 5, though not IE9.

We added this behavior on  issue 2820  to fix a variety of problems in languages like Japanese.  Because those problems resulted in users unable to navigate to the pasted links, whereas this issue seems to be solely about cosmetics (in that escaped URLs are ugly and hard to read), preserving that behavior change seems like the more important thing to do.

Workarounds

Few things can be done if this issue is affecting your day to day usage of Google Chrome…

  • Before copying the URL add any character at the end of it, then erase it. After this operation the copied URL will preserve its structure not producing punycode when pasted.
  • Use the COPY URL extension.
  • Use a different browser. Microsoft Edge on Windows and Safari on OSX are producing the expected results.

Featured Image: https://wallpapercave.com/w/A7ZAUTz

TortoiseGIT Disconnected: No supported authentication methods available ( server sent: publickey )

After migrating to SSH authentication for my Bitbucket repo ( one of the reasons for doing that was to be able to mirror my repo on my home server, article on that topic coming soon ), the TortoiseGIT windows client stopped working. It was unable to do pulls and pushes and all other functionallity related to connecting to the remote GIT. Android Studio and other IDE’s and tools I use on a daily basis, including git command line client were working properly.

Untitled1

TortoiseGIT uses Pageant (part of the PuTTY toolset) to manage it’s authentication keys. Because I have already generated the public / private key pair using ssh-keygen all I needed to do was make Pageant aware of them.

For this Puttygen (part of the PuTTY toolset) should be used.

Untitled4

pass

Load the key in Puttygen (you will be prompted for password during the loading process), leave the default settings. If the import was successful you will get a message telling you so.

success

Then click ‘Save private key’ button and save your private key in putty default ppk format. Fire up Pageant and load your newly created key.

Untitled6

Now pulls, pushes and all other functionallity related to connecting to the remote GIT should work as expected.

Untitled7

NOTE: Pageant should be started prior to using TortoiseGIT, else you will get the same error message again.