duanlie4621 2015-10-20 14:13
浏览 35

选择一个秘密

I am currently doing a little study on what I can possibly do to secure the cookie data I send to my client. It turns out that it all boils down to signing my cookies - not a big deal, right?

Well, actually, that is only partially true. I am stuck at deciding what secret to use. You see, my app is open-sourced and I won't suddenly close the open source code down. So I need a mechanism that'd allow me to keep the secret a serious secret, and make sure the end user, that reads through my code, won't immediately be able to break through. Because, anything is hackable if you tinker with it long enough - that's how I see it.

Anyway I am getting off topic.

I am working with PHP and NodeJS. What are the best ways to pick a secret, that will forever stay a secret?

My initial thoughts: - My server's private key - A random string, put into a text file outside of world-access

My app currently runs Yii1, but I am switching to laravel 5.

  • 写回答

1条回答 默认 最新

  • dta43039 2015-10-20 16:12
    关注

    It turns out that it all boils down to signing my cookies - not a big deal, right?

    Be very careful here. Many people attempted to implement such a feature before, only to render their apps remotely exploitable.

    I would almost argue that you shouldn't write this yourself. One of the features I'm building for my libsodium wrapper library is an authenticated encryption wrapper for HTTP cookies.

    What are the best ways to pick a secret, that will forever stay a secret?

    Easiest: Using 32 bytes from /dev/urandom, stored in a configuration file outside of your document root.

    Most secure: Use a HSM so your keys are never accessible, even if an attacker gets root on your server.

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?