msencrypt(1)
π NAME
msencrypt β bestie, this one makes encryption keys, or it encrypts little chunks of your connection strings so you can stash them in mapfiles π
β¨ SYNOPSIS
msencrypt [-keygen file | -key file string]
π¦ DESCRIPTION
So msencrypt does two things, and honestly both are iconic: it can create an encryption key, and it can encrypt portions of connection strings for use in mapfiles. No cap. π
Like, the classic glow-up situation is that you wanna encrypt portions of the CONNECTION parameter for a database connection. Because putting your raw password in a mapfile? We don't do that here. π
These CONNECTIONTYPEs are the ones supported for using this encryption method:
OGROracle SpatialPostGISSDE
πΈ OPTIONS
-keygenfile β Creates a new encryption key in file. New key, fresh start, main character energy. πβ¨-keyfile string β Use the key in file to encrypt string. Periodt.
π NOTES
Use in Mapfile.
Where does the encryption key live? Two mechanisms, pick your fighter:
- setting the environment variable
MS_ENCRYPTION_KEY, or - using a
CONFIGdirective in theMAPobject of your mapfile.
For example:
CONFIG MS_ENCRYPTION_KEY "/path/to/mykey.txt"
And when you're dropping encrypted strings inside database CONNECTIONs in your mapfile, use the { and } characters as delimiters. Like this:
CONNECTIONTYPE ORACLESPATIAL
CONNECTION "user/{MIIBugIBAAKBgQCP0Yj+Seh8==}@service"
The curly braces are literally the whole vibe. Don't skip them. π«Ά
π EXAMPLE
Okay bestie, here's a whole layer to look at:
LAYER
NAME "provinces"
TYPE POLYGON
CONNECTIONTYPE POSTGIS
CONNECTION "host=127.0.0.1 dbname=gmap user=postgres password=iluvyou18 port=5432"
DATA "the_geom FROM province using SRID=42304"
STATUS DEFAULT
CLASS
NAME "Countries"
COLOR 255 0 0
END
END
Here are the steps to encrypt the password in the above connection:
- Generate an encryption key β and note that this key should not be stored anywhere within your web server's accessible directories:
msencrypt -keygen "/home/user/mykey.txt"
And this generated key file might contain something like:
2137FEFDB5611448738D9FBB1DC59055
- Encrypt the connection's password using that generated key:
msencrypt -key "/home/user/mykey.txt" "iluvyou18"
Which returns the password encrypted, at the commandline (you'll use it in a second):
3656026A23DBAFC04C402EDFAB7CE714
- Edit the mapfile to make sure the
'mykey.txt'can be found, using the"MS_ENCRYPTION_KEY"environment variable. TheCONFIGparameter inside theMAPobject can be used to set an environment variable inside a mapfile:
MAP
...
CONFIG "MS_ENCRYPTION_KEY" "/home/user/mykey.txt"
...
END #mapfile
- Modify the layer's
CONNECTIONto use the generated password key, making sure to use the"{}"brackets around the key:
CONNECTION "host=127.0.0.1 dbname=gmap user=postgres
password={3656026A23DBAFC04C402EDFAB7CE714} port=5432"
- Done! Give your new encrypted mapfile a try with the
map2img(1)utility!
You did it. Your secrets are safe, your mapfile is encrypted, and you are absolutely serving. ππ
That's the whole page, bestie β msencrypt(1), dated 22 August 2026. Go forth and encrypt, slay, and never commit a plaintext password again. π¦β¨π
π¦ where this page comes from
- ubuntu stonking: mapserver-bin 8.6.5-1build1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms