-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ssl-certificate-checker): add SSL Certificate Checker support (#…
…4734) Co-authored-by: Fabio Martino <[email protected]>
- Loading branch information
1 parent
74b93d7
commit 51d82f5
Showing
3 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# SSLCertificateChecker | ||
|
||
``` | ||
$ ionic cordova plugin add cordova-plugin-sslcertificatechecker | ||
$ npm install @awesome-cordova-plugins/ssl-certificate-checker | ||
``` | ||
|
||
## [Usage Documentation](https://danielsogl.gitbook.io/awesome-cordova-plugins/plugins/ssl-certificate-checker/) | ||
|
||
Plugin Repo: [https://github.com/EddyVerbruggen/SSLCertificateChecker-PhoneGap-Plugin](https://github.com/EddyVerbruggen/SSLCertificateChecker-PhoneGap-Plugin) | ||
|
||
Cordova plugin to check SSL certificates on Android and iOS. | ||
|
||
## Supported Platforms | ||
|
||
* Android | ||
* iOS |
17 changes: 17 additions & 0 deletions
17
docs/plugins/ssl-certificate-checker/ssl-certificate-checker.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# SSLCertificateChecker | ||
|
||
``` | ||
$ ionic cordova plugin add cordova-plugin-sslcertificatechecker | ||
$ npm install @awesome-cordova-plugins/ssl-certificate-checker | ||
``` | ||
|
||
## [Usage Documentation](https://github.com/EddyVerbruggen/SSLCertificateChecker-PhoneGap-Plugin/) | ||
|
||
Plugin Repo: [https://github.com/EddyVerbruggen/SSLCertificateChecker-PhoneGap-Plugin](https://github.com/EddyVerbruggen/SSLCertificateChecker-PhoneGap-Plugin) | ||
|
||
Cordova plugin to check SSL certificates on Android and iOS. | ||
|
||
## Supported Platforms | ||
|
||
* Android | ||
* iOS |
62 changes: 62 additions & 0 deletions
62
src/@awesome-cordova-plugins/plugins/ssl-certificate-checker/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Plugin, Cordova, AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core'; | ||
|
||
/** | ||
* @name SSLCertificateChecker | ||
* @description | ||
* Cordova plugin to check SSL certificates on Android and iOS. | ||
* | ||
* @usage | ||
* ```typescript | ||
* import { SSLCertificateChecker } from '@awesome-cordova-plugins/ssl-certificate-checker'; | ||
* | ||
* constructor(private sslCertificateChecker: SSLCertificateChecker) { } | ||
* | ||
* ... | ||
* | ||
* this.sslCertificateChecker.check(serverURL, allowedFingerprint) | ||
* .then(() => console.log('Certificate is valid')) | ||
* .catch(error => console.error('Certificate is invalid', error)); | ||
* | ||
* ... | ||
* | ||
* this.sslCertificateChecker.checkInCertChain(serverURL, allowedFingerprint) | ||
* .then(() => console.log('Certificate chain is valid')) | ||
* .catch(error => console.error('Certificate chain is invalid', error)); | ||
* | ||
* ``` | ||
*/ | ||
@Plugin({ | ||
pluginName: 'SSLCertificateChecker', | ||
plugin: 'SSLCertificateChecker-PhoneGap-Plugin', | ||
pluginRef: 'SSLCertificateChecker', | ||
repo: 'https://github.com/EddyVerbruggen/SSLCertificateChecker-PhoneGap-Plugin', | ||
platforms: ['Android', 'iOS'], | ||
}) | ||
@Injectable() | ||
export class SSLCertificateChecker extends AwesomeCordovaNativePlugin { | ||
/** | ||
* Checks if the SSL certificate of the specified server matches the provided fingerprint. | ||
* @param serverURL - The URL of the server to check. | ||
* @param allowedFingerprint - The allowed SHA-1 fingerprint. | ||
* @return {Promise<void>} Returns a promise that resolves if the certificate is valid, otherwise rejects with an error. | ||
*/ | ||
@Cordova() | ||
check(serverURL: string, allowedFingerprint: string): Promise<void> { | ||
return; | ||
} | ||
|
||
/** | ||
* (Not recommended in versions higher than 4.0.0) | ||
* Checks if the SSL certificate of the specified server is in the certificate chain | ||
* and matches the provided fingerprint. | ||
* @param serverURL - The URL of the server to check. | ||
* @param allowedFingerprint - The allowed SHA-1 fingerprint. | ||
* @return {Promise<void>} Returns a promise that resolves if the certificate chain is valid, otherwise rejects with an error. | ||
* @deprecated This function is considered insecure. | ||
*/ | ||
@Cordova() | ||
checkInCertChain(serverURL: string, allowedFingerprint: string): Promise<void> { | ||
return; | ||
} | ||
} |