Skip to content

Commit

Permalink
Añadido https a restapi
Browse files Browse the repository at this point in the history
  • Loading branch information
Uo284548 authored and Uo284548 committed Apr 30, 2023
1 parent 5d984e6 commit 8f49248
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 7 deletions.
18 changes: 17 additions & 1 deletion restapi/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@ import cors from 'cors'
import getConfig from "./config"
import routes from './routes'
import errorHandler from "./middlewares/errorHandler"
import { readFileSync } from "fs"
import { createServer } from "https"

const app: Application = express()

app.disable('x-powered-by')

const port=getConfig().port
app.set('port', getConfig().port)

app.use(cors())
app.use(express.json())
app.use(express.urlencoded({ extended: true }))

var privateKey = readFileSync("src/certificates/host.key");
var certificate = readFileSync("src/certificates/host.cert");
var credentials = { key: privateKey, cert: certificate };

app.get('/api', (req, res) => {
res.status(200).json({ message: 'LoMap restAPI' })
})
Expand All @@ -23,4 +30,13 @@ app.use('/api/image', routes.images)

app.use(errorHandler)

export default app
createServer(credentials, app)
.listen(port, (): void => {
console.log("Restapi listening on " + port);
})
.on("error", (error: Error) => {
console.error("Error occured: " + error.message);
});

export default app

125 changes: 125 additions & 0 deletions restapi/src/certificates/host.cert
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 1 (0x1)
Signature Algorithm: sha1WithRSAEncryption
Issuer: C=FR, ST=Alsace, L=Strasbourg, O=www.freelan.org, OU=freelan, CN=Freelan Sample Certificate Authority/emailAddress=contact@freelan.org
Validity
Not Before: Apr 27 10:31:18 2012 GMT
Not After : Apr 25 10:31:18 2022 GMT
Subject: C=FR, ST=Alsace, O=www.freelan.org, OU=freelan, CN=alice/emailAddress=contact@freelan.org
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (4096 bit)
Modulus:
00:dd:6d:bd:f8:80:fa:d7:de:1b:1f:a7:a3:2e:b2:
02:e2:16:f6:52:0a:3c:bf:a6:42:f8:ca:dc:93:67:
4d:60:c3:4f:8d:c3:8a:00:1b:f1:c4:4b:41:6a:69:
d2:69:e5:3f:21:8e:c5:0b:f8:22:37:ad:b6:2c:4b:
55:ff:7a:03:72:bb:9a:d3:ec:96:b9:56:9f:cb:19:
99:c9:32:94:6f:8f:c6:52:06:9f:45:03:df:fd:e8:
97:f6:ea:d6:ba:bb:48:2b:b5:e0:34:61:4d:52:36:
0f:ab:87:52:25:03:cf:87:00:87:13:f2:ca:03:29:
16:9d:90:57:46:b5:f4:0e:ae:17:c8:0a:4d:92:ed:
08:a6:32:23:11:71:fe:f2:2c:44:d7:6c:07:f3:0b:
7b:0c:4b:dd:3b:b4:f7:37:70:9f:51:b6:88:4e:5d:
6a:05:7f:8d:9b:66:7a:ab:80:20:fe:ee:6b:97:c3:
49:7d:78:3b:d5:99:97:03:75:ce:8f:bc:c5:be:9c:
9a:a5:12:19:70:f9:a4:bd:96:27:ed:23:02:a7:c7:
57:c9:71:cf:76:94:a2:21:62:f6:b8:1d:ca:88:ee:
09:ad:46:2f:b7:61:b3:2c:15:13:86:9f:a5:35:26:
5a:67:f4:37:c8:e6:80:01:49:0e:c7:ed:61:d3:cd:
bc:e4:f8:be:3f:c9:4e:f8:7d:97:89:ce:12:bc:ca:
b5:c6:d2:e0:d9:b3:68:3c:2e:4a:9d:b4:5f:b8:53:
ee:50:3d:bf:dd:d4:a2:8a:b6:a0:27:ab:98:0c:b3:
b2:58:90:e2:bc:a1:ad:ff:bd:8e:55:31:0f:00:bf:
68:e9:3d:a9:19:9a:f0:6d:0b:a2:14:6a:c6:4c:c6:
4e:bd:63:12:a5:0b:4d:97:eb:42:09:79:53:e2:65:
aa:24:34:70:b8:c1:ab:23:80:e7:9c:6c:ed:dc:82:
aa:37:04:b8:43:2a:3d:2a:a8:cc:20:fc:27:5d:90:
26:58:f9:b7:14:e2:9e:e2:c1:70:73:97:e9:6b:02:
8e:d3:52:59:7b:00:ec:61:30:f1:56:3f:9c:c1:7c:
05:c5:b1:36:c8:18:85:cf:61:40:1f:07:e8:a7:06:
87:df:9a:77:0b:a9:64:72:03:f6:93:fc:e0:02:59:
c1:96:ec:c0:09:42:3e:30:a2:7f:1b:48:2f:fe:e0:
21:8f:53:87:25:0d:cb:ea:49:f5:4a:9b:d0:e3:5f:
ee:78:18:e5:ba:71:31:a9:04:98:0f:b1:ad:67:52:
a0:f2:e3:9c:ab:6a:fe:58:84:84:dd:07:3d:32:94:
05:16:45:15:96:59:a0:58:6c:18:0e:e3:77:66:c7:
b3:f7:99
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
Netscape Comment:
OpenSSL Generated Certificate
X509v3 Subject Key Identifier:
59:5F:C9:13:BA:1B:CC:B9:A8:41:4A:8A:49:79:6A:36:F6:7D:3E:D7
X509v3 Authority Key Identifier:
keyid:23:6C:2D:3D:3E:29:5D:78:B8:6C:3E:AA:E2:BB:2E:1E:6C:87:F2:53

Signature Algorithm: sha1WithRSAEncryption
13:e7:02:45:3e:a7:ab:bd:b8:da:e7:ef:74:88:ac:62:d5:dd:
10:56:d5:46:07:ec:fa:6a:80:0c:b9:62:be:aa:08:b4:be:0b:
eb:9a:ef:68:b7:69:6f:4d:20:92:9d:18:63:7a:23:f4:48:87:
6a:14:c3:91:98:1b:4e:08:59:3f:91:80:e9:f4:cf:fd:d5:bf:
af:4b:e4:bd:78:09:71:ac:d0:81:e5:53:9f:3e:ac:44:3e:9f:
f0:bf:5a:c1:70:4e:06:04:ef:dc:e8:77:05:a2:7d:c5:fa:80:
58:0a:c5:10:6d:90:ca:49:26:71:84:39:b7:9a:3e:e9:6f:ae:
c5:35:b6:5b:24:8c:c9:ef:41:c3:b1:17:b6:3b:4e:28:89:3c:
7e:87:a8:3a:a5:6d:dc:39:03:20:20:0b:c5:80:a3:79:13:1e:
f6:ec:ae:36:df:40:74:34:87:46:93:3b:a3:e0:a4:8c:2f:43:
4c:b2:54:80:71:76:78:d4:ea:12:28:d8:f2:e3:80:55:11:9b:
f4:65:dc:53:0e:b4:4c:e0:4c:09:b4:dc:a0:80:5c:e6:b5:3b:
95:d3:69:e4:52:3d:5b:61:86:02:e5:fd:0b:00:3a:fa:b3:45:
cc:c9:a3:64:f2:dc:25:59:89:58:0d:9e:6e:28:3a:55:45:50:
5f:88:67:2a:d2:e2:48:cc:8b:de:9a:1b:93:ae:87:e1:f2:90:
50:40:d9:0f:44:31:53:46:ad:62:4e:8d:48:86:19:77:fc:59:
75:91:79:35:59:1d:e3:4e:33:5b:e2:31:d7:ee:52:28:5f:0a:
70:a7:be:bb:1c:03:ca:1a:18:d0:f5:c1:5b:9c:73:04:b6:4a:
e8:46:52:58:76:d4:6a:e6:67:1c:0e:dc:13:d0:61:72:a0:92:
cb:05:97:47:1c:c1:c9:cf:41:7d:1f:b1:4d:93:6b:53:41:03:
21:2b:93:15:63:08:3e:2c:86:9e:7b:9f:3a:09:05:6a:7d:bb:
1c:a7:b7:af:96:08:cb:5b:df:07:fb:9c:f2:95:11:c0:82:81:
f6:1b:bf:5a:1e:58:cd:28:ca:7d:04:eb:aa:e9:29:c4:82:51:
2c:89:61:95:b6:ed:a5:86:7c:7c:48:1d:ec:54:96:47:79:ea:
fc:7f:f5:10:43:0a:9b:00:ef:8a:77:2e:f4:36:66:d2:6a:a6:
95:b6:9f:23:3b:12:e2:89:d5:a4:c1:2c:91:4e:cb:94:e8:3f:
22:0e:21:f9:b8:4a:81:5c:4c:63:ae:3d:05:b2:5c:5c:54:a7:
55:8f:98:25:55:c4:a6:90:bc:19:29:b1:14:d4:e2:b0:95:e4:
ff:89:71:61:be:8a:16:85
-----BEGIN CERTIFICATE-----
MIIGJzCCBA+gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBsjELMAkGA1UEBhMCRlIx
DzANBgNVBAgMBkFsc2FjZTETMBEGA1UEBwwKU3RyYXNib3VyZzEYMBYGA1UECgwP
d3d3LmZyZWVsYW4ub3JnMRAwDgYDVQQLDAdmcmVlbGFuMS0wKwYDVQQDDCRGcm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AwEAAaN7MHkwCQYDVR0TBAIwADAsBglghkgBhvhCAQ0EHxYdT3BlblNT
TCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFFlfyRO6G8y5qEFKikl5
ajb2fT7XMB8GA1UdIwQYMBaAFCNsLT0+KV14uGw+quK7Lh5sh/JTMA0GCSqGSIb3
DQEBBQUAA4ICAQAT5wJFPqervbja5+90iKxi1d0QVtVGB+z6aoAMuWK+qgi0vgvr
mu9ot2lvTSCSnRhjeiP0SIdqFMORmBtOCFk/kYDp9M/91b+vS+S9eAlxrNCB5VOf
PqxEPp/wv1rBcE4GBO/c6HcFon3F+oBYCsUQbZDKSSZxhDm3mj7pb67FNbZbJIzJ
70HDsRe2O04oiTx+h6g6pW3cOQMgIAvFgKN5Ex727K4230B0NIdGkzuj4KSML0NM
slSAcXZ41OoSKNjy44BVEZv0ZdxTDrRM4EwJtNyggFzmtTuV02nkUj1bYYYC5f0L
ADr6s0XMyaNk8twlWYlYDZ5uKDpVRVBfiGcq0uJIzIvemhuTrofh8pBQQNkPRDFT
Rq1iTo1Ihhl3/Fl1kXk1WR3jTjNb4jHX7lIoXwpwp767HAPKGhjQ9cFbnHMEtkro
RlJYdtRq5mccDtwT0GFyoJLLBZdHHMHJz0F9H7FNk2tTQQMhK5MVYwg+LIaee586
CQVqfbscp7evlgjLW98H+5zylRHAgoH2G79aHljNKMp9BOuq6SnEglEsiWGVtu2l
hnx8SB3sVJZHeer8f/UQQwqbAO+Kdy70NmbSaqaVtp8jOxLiidWkwSyRTsuU6D8i
DiH5uEqBXExjrj0FslxcVKdVj5glVcSmkLwZKbEU1OKwleT/iXFhvooWhQ==
-----END CERTIFICATE-----
51 changes: 51 additions & 0 deletions restapi/src/certificates/host.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
-----BEGIN RSA PRIVATE KEY-----
MIIJKQIBAAKCAgEA3W29+ID6194bH6ejLrIC4hb2Ugo8v6ZC+Mrck2dNYMNPjcOK
AB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NLk2Euzw3
EbRidI61mtGNikIF+PAAN+YgFJbXYK5I5jjIDs5JJohIkKaP9c5AJbxnpGslvLg/
IDrFXBc22YY9QTa4YldCi/eOrP0eLIANs95u3zXAqwPBnh1kgG9pYsbuGy5Fh4kp
q7WSpLYo1kQo6J8QQAdhLVh4B7QIsU7GQYGm0djCR81Mt2o9nCW1nEUUnz32YVay
ASM/Q0eip1I2kzSGPLkHww2XjjjkD1cZfIhHnYZ+kO3sV92iKo9tbFOLqmbz48l7
RoplFQKCAQEA6i+DcoCL5A+N3tlvkuuQBUw/xzhn2uu5BP/kwd2A+b7gfp6Uv9lf
P6SCgHf6D4UOMQyN0O1UYdb71ESAnp8BGF7cpC97KtXcfQzK3+53JJAWGQsxcHts
Q0foss6gTZfkRx4EqJhXeOdI06aX5Y5ObZj7PYf0dn0xqyyYqYPHKkYG3jO1gelJ
T0C3ipKv3h4pI55Jg5dTYm0kBvUeELxlsg3VM4L2UNdocikBaDvOTVte+Taut12u
OLaKns9BR/OFD1zJ6DSbS5n/4A9p4YBFCG1Rx8lLKUeDrzXrQWpiw+9amunpMsUr
rlJhfMwgXjA7pOR1BjmOapXMEZNWKlqsPQKCAQByVDxIwMQczUFwQMXcu2IbA3Z8
Czhf66+vQWh+hLRzQOY4hPBNceUiekpHRLwdHaxSlDTqB7VPq+2gSkVrCX8/XTFb
SeVHTYE7iy0Ckyme+2xcmsl/DiUHfEy+XNcDgOutS5MnWXANqMQEoaLW+NPLI3Lu
V1sCMYTd7HN9tw7whqLg18wB1zomSMVGT4DkkmAzq4zSKI1FNYp8KA3OE1Emwq+0
wRsQuawQVLCUEP3To6kYOwTzJq7jhiUK6FnjLjeTrNQSVdoqwoJrlTAHgXVV3q7q
v3TGd3xXD9yQIjmugNgxNiwAZzhJs/ZJy++fPSJ1XQxbd9qPghgGoe/ff6G7
-----END RSA PRIVATE KEY-----
10 changes: 5 additions & 5 deletions restapi/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const metricsMiddleware:RequestHandler = promBundle({includeMethod: true})
app.use(metricsMiddleware)
app.use(cors())

app.listen(app.get('port'), () : void => {
console.log('Restapi listening on '+ app.get('port'))
}).on("error",(error:Error)=>{
console.error('Error occured: ' + error.message)
});
// app.listen(app.get('port'), () : void => {
// console.log('Restapi listening on '+ app.get('port'))
// }).on("error",(error:Error)=>{
// console.error('Error occured: ' + error.message)
// });
2 changes: 1 addition & 1 deletion webapp/src/components/AddMarkerPopup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function AddPopup({ visible, closePopup, addMark, lngLat }: Props){

let formData = new FormData()
formData.append('image',filepreview)
const apiEndPoint = process.env.REACT_APP_API_URI || 'http://localhost:5000/api'
const apiEndPoint = process.env.REACT_APP_API_URI || 'https://localhost:5000/api'
const response = await fetch(apiEndPoint+'/image/upload',{
method:"POST",
body: formData
Expand Down

0 comments on commit 8f49248

Please sign in to comment.