Closed ImCarrot closed 6 years ago
Encryption of vector tiles is not part of specification nor this implementation. Maybe you've to look at other methods of data distribution (like webservices with proper authentication/authorisation) to reach your goal. Closing this issue for now.
Hi, I'll try to be brief, but I'll share the whole picture.
I am using vector tile from tippecanoe from
mapbox
to create.pbtiles
from mygeojson
data. The issue is, on a web client when I see theinspect element
and download the.pbf
and run it by this (mapbox-vector-tile-cs) library, I am able to successfully get the data from the tile. Which means that any one with some basic google search can also steal my data from the vector tiles.To avoid the security concern, with the short timeline I have, I came up with a quick and dirty way. After
tippecanoe
creates the.mbtiles
sqlite db, I run a java utility I made to encrypt the data in theblob
usingAES 256
encryption and stored it in two different ways in two different sqlite db's:Stored as bytes into a different
.mbtiles
sqlite db (which get's stored as Blob). Along withz, x, y
andmetadata
Encoded the encrypted data as
base64
and then stored the base64encoded encrypted tile data into a string data type column. Along withz, x, y
andmetadata
.and stored the key (base64 encoded) and initialization vector (base64 encoded) into a file.
Now, when I get the non encrypted
.pbf
from the API, a header of typegzip
andapplication/x-protobuf
is set that helps to convert the unencryptedblob
data to aprotobuf
and returns a.pbf
file that gets downloaded.Now when I try to get the encrypted data from the API with the same header as the non encrypted on, the download of the
.pbf
fails sayingFailed - Network error
. I realized that it's being caused as the headerapplication/x-protobuf
is trying to package the file into a.pbf
while the contents of the blob might not be matching what's expected and hence the result.I removed the header
application/x-protobuf
and since I can'tgzip
now, i removed the header ofgzip
too. Now the data gets displayed on the chrome browser instead of being downloaded, I figure as now it's just a random response.The question is, How can I make it to send a
.pbf
that has encrypted data in it and this((mapbox-vector-tile-cs)) library can parse the data? I know the data will be need to be decrypted first before I pass it forparsing
assuming that it's decrypted and I have the data that was stored into theblob
of the.mbtiles
.So now currently as mentioned above (since i don't have a solution to the headers part) I removed the headers and let the API return me a direct response.
The Issue now I am facing is that when I pass in the decryted (I checked the decryption was successful and the decrypted data is an exact match to the what was stored in the
Blob
) Blob data to thevar layerInfos = VectorTileParser.Parse(stream);
code line returns me an
IEnumerable<Tile>
that isnot null
but has0 layers
in it. while the actual tile contains5 layers
in it.My Question is, how do I get this((mapbox-vector-tile-cs)) library to return me the layers.
The code to fetch the tile from the server and decrypt before I send it for
parsing
is as below:The tiles are fetched from the server using a
GetTileFromWeb()
method:PS: Sorry for such a long question, I am not used to such elaborate detail, but seemed I need to share more as Encryption is my forte while map data vector tiles isn't.