Pattern cannot match values of type ‘LABiometryType’ in ionic project

I’m getting the following errors while building my ionic 4 app, This error came from a cordova plugin called cordova-plugin-fingerprint-aio , After a long research i fixed this issue by modifying the code in the plugin core files.

File location: src/ios/Fingerprint.swift

Actual code ( Swift )

switch(authenticationContext.biometryType) {
    case .none:
        biometryType = "none";
    case .touchID:
        biometryType = "finger";
    case .faceID:
        biometryType = "face"
}

Modified code

switch(authenticationContext.biometryType) {
	case LABiometryType.none:
	    biometryType = "none";
	case LABiometryType.typeTouchID:
	    biometryType = "finger";
	case LABiometryType.typeFaceID:
	    biometryType = "face"
}

The changes fixed the issues and app is working fine. You must remove and add the ios platform again to reflect the changes

PS: I’m not a Swift programmer and i won’t say that the above solution is perfect

Typescript observable example

Context

Recently, I wanted to use observable in one of my ionic 4 project, client wanted to show a progress bar during the file uploading process, So that i decided to use it and googled for the example, but unfortunately i did’t find any best Typescript observable example that fulfill my needs and i spent so much time to make it work as i expected, that why i’m writing this post to share a sample code for the same.

Code Samples

    testObservable() {
	var i = 0;
        return  new Observable<Upload>((observer) => {
		var int = setInterval(()=>{
			i++;
			var data = {
				status: 'In progress',
				url: 'bbbb',
				percent: ( i / 10 )
			};
			console.log(i);
			console.log((i==10));
			if(i>9){
				clearInterval(int);
				data.status= 'Completed';
				observer.next(data);
				observer.complete();
			}
			observer.next(data);
			console.log(data);
		},1500);
        });
    }
class Upload {
	public status: string;
	public url: string;
	public percent: number;
}
this.obsData$ = this.testObservable();
this.obsData$.subscribe(
	(responseObj: any) => { // On next 
		console.log(responseObj);
	},
	(error:any) => console.log(error),
	() => { // On complete
	}
)

HTML page

<p>{{ ( obsData$ | async )?.status}}</p>
<ion-progress-bar value="{{( obsData$ | async )?.percent }}"></ion-progress-bar>

You may contact me if you need any further help
Sijo Vijayan

How to make phpmyadmin publicly available in aws ec2 bitnami ubuntu 16.04

Introduction

This article will be helpful for those who is using Ubuntu 16.04 – bitnami based server on amazon aws EC2 instance only. In this post i’m explaining how make phpmyadmin publicly available in bitnami based servers.

 

nano /opt/bitnami/apps/phpmyadmin/conf/httpd-app.conf

Use the following rules

<IfVersion < 2.3 >
Order allow,deny
Allow from All
Satisfy all
</IfVersion>
<IfVersion >= 2.3>
Require all granted
</IfVersion>

 

restart apache

sudo /opt/bitnami/ctlscript.sh restart apache

 

After doing the above step phpmyadmin will be accessible using the following url pattern

http://<your domian OR ip>/phpmyadmin

 

 

 

 

Integrate Let’s Encrypt on an Amazon Linux AMI EC2 Instance Using Certbot

I’m using some latest Amazon Machine Image ( AMI ) called LAMP Stack PHP 5.3 LTS, Actually i was using some old AMI that released in 2013 and the instance also created at that time. It was almost impossible for me to integrate certbot in it, so that i finally decided to migrate my codeignitor app into new instance that support php 5.3

Here also i struggled so much to integrate certbot but finally i did it by the following steps.

  1. cd /tmp
  2. git clone https://github.com/certbot/certbot
  3. cd certbot
  4. chmod a+x certbot-auto
  5. ./certbot-auto certonly --webroot -w /var/www/html/ -d <domainName> --debug
  6. sudo ln -s /etc/letsencrypt/live/<domainName>/fullchain.pem /jet/etc/apache//server.crt
    sudo ln -s /etc/letsencrypt/live/<domainName>/privkey.pem /jet/etc/apache//server.key
  7. cd /jet/etc/apache
  8.  nano httpd.conf
  9. uncomment the following line of code in httpd.conf file
  10. Include /jet/etc/apache//extra/httpd-ssl.conf
  11. nano extra/httpd-ssl.conf     // uncomment and set the following things with newly created crt and key file paths
  12. DocumentRoot
  13. ServerName
  14. SSLCertificateFile
  15. SSLCertificateKeyFile
  16. restart service by using the following command
  17. /jet/enter restart

Auto-renew your SSL certificates.

You are all set now. But take a note, Let’s Encrypt’s certificates are only valid for 90 days. This is to encourage users to automate their certificate renewal process. You can setup a cron job which will run everyday at a particular time to renew certificates. Certificates are renewed only when they expire.

  • To test the renewal process, you can do a dry run with certbot:
sudo /tmp/certbot/certbot-auto renew --dry-run

  • Then update the crontab:
sudo crontab -e
  • Then, add the following line to crontab:
12 3 * * *   /tmp/certbot/certbot-auto renew --post-hook "sudo /jet/enter restart" >> /etc/letsencrypt/log/renew.log

This runs the renew everyday at 3:12 am. Remember that certs don’t get renewed unless they are near to expiration, and monthly/weekly cron job would cause your existing certs to occasionally be expired already before they get renewed.

 

You can contact me in case you need any help to setup the above things, I will providing premium support

 

How to use SSL pinning with cordova-plugin-advanced-http ?

Introduction

It’s little bit complex task for the new programmers to use SSL pinning with cordova-plugin-advanced-http plugin. Plugin installation and usage is not so complex, but most of the people have no idea about how to obtain the .cer file for SSL pinning purpose.

I have already published a blog post about how to generate the .cer file, You may just read this blog post first.

In my project i just want to use an HTTPs based url from my ionic application, My client told me its very important for him because we are transferring some sensitive data through this API.

Firstly, I just installed the cordova-plugin-advanced-http plugin and its npm module in our ionic project and then i search on google to find how to generate .cer file. Most of the results just showing some results about how to convert a .pem file to .crt file and actually not solving my issues.

Example ionic application

I have created a git repository to share my sample application

Git URL https://github.com/sijovijayan/SSL-pinning-with-ionic-cordova-example

Or

Download

SSL Pinning may not work properly with Live Reload mode

Thanks

 

How to integrate SSL in ionic 3 using cordova plugin

Introduction

It was a little bit hard task for me to integrate SSL in my Ionic 3 app using Cordova due to my lack of knowledge in SSL certificates. As usual i just landed in the HTTP native plugin section under ionic frameworks documentation section. It was not so helpful for me, because neither  this page or its official github page not explaining how to generate the .cer file for SSL pinning, finally i found the solution by reading lots of Stackoverflow answers and other articles.

Procedure

Install the plugin as per the instruction on the documentation section

How to get the .cer file ?

I’m assuming that you need to make https requests to a single domain only

Method 1

It works only if you had chrome browser on a windows machine with no active antivirus software ( In my case kaspersky using a personal root certificate – that mask the actual SSL certificate keyfile from the user  )

In this case, we can generate .cer file from your chrome browser on windows machine. Just access one of your public api url via chrome browser address bar and then click on the green padlock icon of your https url. then you can export the ssl public key as a .cer file

Watch this video to get clear understanding

 

Method 2 ( recommended one )

If you have a Linux or Mac machine or use you Linux server terminal – If your machine must have an installation of openssl.

Use the following linux command to obtain the .cer file

openssl s_client -showcerts -connect <domain name>:443 -servername <domain name>:443 </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > certificate.pem

Convert .pem file into .cer file

openssl x509 -inform PEM -in certificate.pem -outform DER -out certificate.cer

Download the certificate.cer file to your local machine and then include a copy on your ionic/cordova project root directory

You must call enableSSLPinning or setSSLCertMode method on your components.ts file based on the version of the installed plugin

That’s all!

How to setup subdomain and virtual host in ubuntu 16.04 bitnami server

Introduction

This article will be helpful for those who is using Ubuntu 16.04 – bitnami based server on amazon aws EC2 instance only. I’m writing this blog post because, i did’t find any best blogs which explain how to create a subdomain in aws ec2 instance and which also using bitnami based image to configure the instance. I can see, so many blogs and stackoverflow results about this topic, but most of those are talking about creation of virtual host on the standard ubuntu server only. Actually creation of the virtual host was the complex task for me at first and subdomain creation is almost easy.

subdomain-virtual-host-on-bitnami-ubuntu-aws-ec2

Steps to create virtual host and create subdomain in bitnami based ubuntu server

  1. Login on your sever via terminal window with bitnami as the user
  2. Copy demo directory from /home/bitnami/stack/docs/demo to a new location ( You may rename the directory “demo” as something else )
  3. Change the path and hostname on the config files on the new demo directory with new file paths ( in my example, it is located in /home/bitnami/htdocs/demo )
  4. Include the path /home/bitnami/htdocs/demo/conf/httpd-vhosts.conf  on the /home/bitnami/stack/apache2/conf/bitnami/bitnami-apps-vhosts.conf file
  5. Restart the apache2 server ( sudo /opt/bitnami/ctlscript.sh restart )
    (  Virtual host creatio has been completed )
  6. Create a subdomain record ( ‘A’ Record ) on aws route53
  7. Check the sub domain on the browser after 5 minutes
  8. Upload your files to your subdomain root directory
  9. Hire me if you need more help ( optional  🙂

Please watch this video to get more clarity on this.

how to connect to aws ec2 instance from windows computer without putty

Hello Techies,

I don’t really like to use putty because i’m a linux user for development. Recently i wanted to connect to an AWS EC2 instance from my windows 10 pc, AWS recommended to use Putty or their CLI. But I don’t like none of those methods, we cannot use windows command prompt or power shell to accomplish the same without doing some modification on the system. So that i connected to aws using GitBash tools.

 

Use GitBash

It is very easy to use for a linux user, because GitBash support some linux commands like ls, ls -la , whoami etc..

First of all we need to locate our  private key file (.pem) file on our pc, I have already downloaded the pem file from aws when i created my ec2 instance. Right now its located in my ‘downloads’ folder so that, i just changed the current directory of gitbash to ‘downloads’ folder using cd command.

As i said before, my pem file is located in downloads folder, so that now i can run the command to connect to aws using my pem file called sijo.pem

ssh -i “SIJO.pem” ubuntu@ec2-54-202-69-35.us-west-2.compute.amazonaws.com

Now, my gitbash connected to my aws ec2 instance as show in the following picture.

gitbash

 

This is how to use SSH connection from windows machine without PUTTY. You can also connect to a linux server from gitbash without pem file as well.

I hope this post will be helpful for someone.

 

Thanks

How to download all files from a web server using your linux machine

If you have enough experience in linux server or similar things then only use the following solution.

The Problem,

I have an Australian client, she want to migrate her websites to another hosting company, ixwebhosting.com was her old hosting company. There were not supporting her for anything related with web server problems like changing php versions and this server blocking suddenly stopped working and not supporting HTTP POST request sometimes. Actually I was working fine before. Finally I suggested to migrate to another hosting company called A2Host, they have some cool pricing plans and almost good technical support.

Actual problem starts when i try to using their ( ixwebhosting ) website control panel, It was not user friendly and don’t have most of the features available in CPanel, There was an Option for zip the project directory in their control panel, but it was not working anyway.  It is not possible to download all the files to my local machine using filezilla and again upload the same to the new service provider.

So, how can i solve this issue ?

Solution

1. I logged in the new webserver ( A2host ) via SSH

Find your webserver host, port number,  username and password , in case of A2H, username and password will be different than your usual login credentials of the control panel

login to the server via linux terminal or user putty in windows

2. Connecting to the old webserver from the current terminal window

Choose your directory you want to save the files being downloaded

use cd <your directory>

connect to the old server via FTP

use

lftp <hostname your using in you desktop ftp client such as filezilla>

ex: lftp web111.ixwebhosting.com

after doing this you have to login to FTP server

use

user <your ftp username>

ex: user webuser

now enter your password

Probably you will be logged in to the FTP server.

use the ls command to list all the directories and files

use the following command to download a particular directory to your new server

mirror <source directory> <target directory>

That’s it

NB: Please use experts help to do the same, otherwise it might cases server issues or data loss