-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathApp.js
More file actions
93 lines (87 loc) · 2.11 KB
/
App.js
File metadata and controls
93 lines (87 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React, {useState} from 'react'
import {StyleSheet, View, Text, Button, Platform} from 'react-native'
const URL = 'https://busdue.com'
const App: () => React$Node = () => {
const [validationMsg, setValidationMsg] = useState('Waiting')
const [validationStatus, setValidationStatus] = useState('')
const onConnectPress = () => {
fetch(URL)
.then((res) => {
console.log('**************')
console.log(res)
console.log('**************')
setValidationMsg('Valid certificate, connected.')
setValidationStatus('success')
})
.catch(() => {
setValidationMsg('Certificate does not match, connection refused')
setValidationStatus('failed')
})
}
return (
<View style={styles.container}>
<Text style={styles.title}>React Native SSL Pinning</Text>
<Text style={styles.title}>({Platform.OS.toUpperCase()})</Text>
<Text style={styles.header}>Certificate status:</Text>
<Text
style={[
styles.status,
validationStatus === 'success' && styles.success,
validationStatus === 'failed' && styles.failed,
]}>
{validationMsg}
</Text>
<View style={styles.btnContainer}>
<Button title={`Test ${URL}`} onPress={onConnectPress} />
</View>
</View>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
padding: 24,
},
title: {
fontSize: 24,
fontWeight: 'bold',
textAlign: 'center',
},
header: {
paddingTop: 46,
fontSize: 18,
textAlign: 'center',
},
status: {
fontSize: 18,
fontWeight: 'bold',
textAlign: 'center',
},
success: {
fontSize: 18,
fontWeight: 'bold',
color: 'green',
},
failed: {
fontSize: 18,
fontWeight: 'bold',
color: 'red',
},
btnContainer: {
borderWidth: 1,
borderColor: 'grey',
borderRadius: 4,
paddingHorizontal: 16,
marginTop: 24,
},
})
export default App