Link Encryption by Batch
Summary | This article is a description of a WebProd feature |
Applies to | AskiaWeb |
Written for | Developers ; security administrators ; field managers |
Keywords | URL ; short ; pretty ; prettify ; webprod ; 5.3.5 ; PowerShell; ps1; link ; encryption ;batch; feature ; highlight |
In 5.3.5, you now have the ability to send survey links with the URL encryption or "prettyfying" (see the article here) . Until now, the encryption can only be done manually, and, was only reserved for StartSurvey link type. That's why we have created a script which allow you to encrypt survey links by batch, based on CSV file. With this script, you can encrypt many URLs at once.
What do you need:
- WebProd version 5.3.5 and above.
- ISAPI filter activated
- ps1 (Script powershell)
1/ The first step is to customise the ps1 attached.
Open it in notepad and modify the line 20 ($server) and replace the 'localhost' by your production server URL (ex: 'web.askia.com'):
2/ Prepare your csv file.
The csv file must at least contain a 'URL' column, with the full link (including the parameters) you want to encrypt:
3/ Run the script from a powershell prompt. You can use these 3 parameters.
- -CsvFileInput: name and path of the input CSV file (mandatory)
- -CsvFileOutput: name and path of the output file (optional: If this is missing, we’ll use the input CSV with -OUTPUT appended)
- -UrlField: name of the field which contains the URL into the csv file (if you're using another name than 'Url' -the default one- into your csv file).
So, in this example, the file is named: file9.csv, and the header for the URL field is 'Url'. The command line will be formatted like this (please note the "." in front of the command line):
."D:\UrlEncryption\EncryptWebProdLinksCsv.ps1" -CsvFileInput "D:\UrlEncryption\file9.csv"
And you will get this into your output file:
A standard DoExternalPanel link with extra parameters . . .
http://10.0.0.67/WebProd/cgi-bin/askiaext.dll?Action=DoExternalPanel&SurveyName=fullurl&Broker=askia&BrokerPanelId=4&tT=ad
. . . will be encrypted like this:
http://10.0.0.67/WebProd/~jgAqch8-_cm6F4j1VIJMvSW8l_cYjUaX
The output CSV also escapes all text fields with quotes. That’s done by Powershell because that’s the correct CSV.
Important:
You can get an error while encrypting a link if the link to encrypt has a length greater than 260 characters. It's because the http.sys service is coded with default maximum of 260 characters per Url segment. The solution here is to add a regkey on the WebProd server. Key to add:
Path: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\HTTP\Parameters
Value: UrlSegmentMaxLength
Type: Reg_DWORD
Data: Desired amount. (Max Value is 32766)
You will need to restarting the PC after having added this key. Have fun!