| 259 | **********************************************************************/ |
| 260 | |
| 261 | static int msLoadEncryptionKey(mapObj *map) |
| 262 | { |
| 263 | const char *keyfile; |
| 264 | |
| 265 | if (map == NULL) |
| 266 | { |
| 267 | msSetError(MS_MISCERR, "NULL MapObj.", "msLoadEncryptionKey()"); |
| 268 | return MS_FAILURE; |
| 269 | } |
| 270 | |
| 271 | if (map->encryption_key_loaded) |
| 272 | return MS_SUCCESS; /* Already loaded */ |
| 273 | |
| 274 | keyfile = msGetConfigOption(map, "MS_ENCRYPTION_KEY"); |
| 275 | |
| 276 | if (keyfile == NULL) |
| 277 | keyfile = getenv("MS_ENCRYPTION_KEY"); |
| 278 | |
| 279 | if (keyfile && |
| 280 | msReadEncryptionKeyFromFile(keyfile,map->encryption_key) == MS_SUCCESS) |
| 281 | { |
| 282 | map->encryption_key_loaded = MS_TRUE; |
| 283 | } |
| 284 | else |
| 285 | { |
| 286 | msSetError(MS_MISCERR, "Failed reading encryption key. Make sure " |
| 287 | "MS_ENCRYPTION_KEY is set and points to a valid key file.", |
| 288 | "msLoadEncryptionKey()"); |
| 289 | return MS_FAILURE; |
| 290 | } |
| 291 | |
| 292 | return MS_SUCCESS; |
| 293 | } |
| 294 | |
| 295 | /********************************************************************** |
| 296 | * msEncryptStringWithKey() |
no test coverage detected