我正在尝试生成一个密钥对,用于Go中的SSH.我似乎正在创建一个私钥,虽然我无法弄清楚如何以正确的格式生成一个公钥.
这是代码:
privateKey, err := rsa.GenerateKey(rand.Reader, 2014)
if err != nil {
return nil, err
}
privateKeyDer := x509.MarshalPKCS1PrivateKey(privateKey)
privateKeyBlock := pem.Block{
Type: "RSA PRIVATE KEY",
Headers: nil,
Bytes: privateKeyDer,
}
privateKeyPem := string(pem.EncodeToMemory(&privateKeyBlock))
publicKey := privateKey.PublicKey
publicKeyDer, err := x509.MarshalPKIXPublicKey(&publicKey)
if err != nil {
return nil, err
}
publicKeyBlock := pem.Block{
Type: "PUBLIC KEY",
Headers: nil,
Bytes: publicKeyDer,
}
publicKeyPem := string(pem.EncodeToMemory(&publicKeyBlock))
fmt.Println(privateKeyPem)
fmt.Println(publicKeyPem)
Run Code Online (Sandbox Code Playgroud)
我得到这个输出:
-----BEGIN RSA PRIVATE KEY-----
MIIEhgIBAAKB/DFnL5O2LCGJQJ/6W299AsrXsHU3nsGVTbjoDqXjdHboSqAuv0ap
oyTPQuBVNff1X0AdVDwjat2vSAukST/3PmRX4TNU4jV0rog/z6grexOCSl3oatJO
i80t+F6uuTD6XTh5C5yDQNI/sTyaPpydbI+P87UuY4UapZaei7fwc3MfurJ+jwEJ
c+jOWbll2YhIgCOuIe0GRX4e4CDC2KiO/BqAWCPQNjk0Y0iC2+J+2Qy3QBOJTVO8
E2DzIhIe4VjKK6OVVesYmJWSXX/Jx382CvUDv5ss8mxGEs3yge4zeQ0GPPDaqTFw
OJ1uppsdj10ZiW92E8v/fYwlBNGfrQIDAQABAoH8C2OCMEcavVBquXZ5haYH8sLu
RtdfnbjRhgLY/Z0FyDOcoHimV5/boCy3egeqvVKvdpRMSuDPTfOOZECnMjvJAlDP
9Yln7HLNmVM8h8QeR00N38Aof/rjd5VVYF5fCs9slgwxhQ8s7ksIjLPyIyCXWjER
OX9MKe8OpT4/b1Pa1X6I28PaC3LVjDHEkigPd705i8VuF2nvZ3+Kb5uQHeczsq6f …Run Code Online (Sandbox Code Playgroud) 因为我在调用expressServer.use(express.session({params}))cookie 时没有定义maxAge,所以将expir 设置为"Session".
我想在登录时添加"记住我"功能.如果选择"记住我",则到期时间将延长至一个月.
我该怎么做呢?我试着简单地扩展maxAge,但这似乎没有做任何事......
expressServer.get '/blah', (request, response) =>
request.session.cookie.maxAge = 2592000
response.end 'hello there'
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助!
**编辑**
我尝试制作一个简单的服务器来测试更新用户的cookie.我正在使用Express 3.0.4
当我访问127.0.0.1:9000/blah时,浏览器cookie的"过期"字段仍然是"会话"...
express = require 'express'
expressServer = express()
expressServer.use express.cookieParser()
expressServer.use express.session
secret: 'supersecret'
cookie:
path: '/'
httpOnly: true
expressServer.get '/', (request, response) =>
response.end 'hello'
expressServer.get '/blah', (request, response) =>
request.session.cookie.maxAge = 3600000
response.end 'hello again'
expressServer.listen 9000
console.log 'server running'
Run Code Online (Sandbox Code Playgroud)
Grrrrrrr ....
我目前正在考虑websockets中的CSRF漏洞.
我已经阻止了所有跨域websocket请求,但是存在脚本(例如这个python坏男孩)来绕过这样的安全措施.
是否值得在用户的index.html中包含一个令牌,它必须作为查询字符串包含在socket.io.connect()调用中?这样在服务器上我们可以检查令牌是否符合预期,否则阻止连接请求.
感谢所有的建议!
由于以下错误,我无法上传文件 jquery.fileupload-image.js:268
Uncaught TypeError: Cannot read property 'parseMetaData' of undefined
我包括以下文件:
ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.js
ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.js
ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.js
maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.js
cdnjs.cloudflare.com/ajax/libs/blueimp-file-upload/9.5.7/jquery.iframe-transport.js
cdnjs.cloudflare.com/ajax/libs/blueimp-file-upload/9.5.7/jquery.fileupload.js
cdnjs.cloudflare.com/ajax/libs/blueimp-file-upload/9.5.7/jquery.fileupload-process.js
cdnjs.cloudflare.com/ajax/libs/blueimp-file-upload/9.5.7/jquery.fileupload-image.js
cdnjs.cloudflare.com/ajax/libs/blueimp-file-upload/9.5.7/jquery.fileupload-audio.js
cdnjs.cloudflare.com/ajax/libs/blueimp-file-upload/9.5.7/jquery.fileupload-video.js
cdnjs.cloudflare.com/ajax/libs/blueimp-file-upload/9.5.7/jquery.fileupload-validate.js
cdnjs.cloudflare.com/ajax/libs/blueimp-file-upload/9.5.7/jquery.fileupload-angular.js
Run Code Online (Sandbox Code Playgroud)
这是我的HTML:
<form data-file-upload="options">
<span class="btn btn-success fileinput-button">
<span>Add files...</span>
<input type="file">
</span>
<button type="button" class="btn btn-primary start" data-ng-click="submit()">
<span>Start upload</span>
</button>
</form>
Run Code Online (Sandbox Code Playgroud)
这是我的Angular:
$scope.options =
url: 'some.endpoint'
Run Code Online (Sandbox Code Playgroud) 我想在我的服务器之间建立一个基于事件的系统.例如,当包装我的数据库逻辑的服务器改变状态时,我希望它通知我的其他服务器.发布/订阅设计似乎是理想的,我听说过有关ZeroRPC的好消息.
有些人提到使用zerorpc流来完成pub/sub,但是对于我来说,使用流媒体触发事件的方式并不明显.
我目前正在使用节点spdy来提供文件.这很好用.
但是,我想使用HAproxy在这些节点服务器之间进行负载平衡.但是当我的节点/ spdy服务器落后于HAproxy时,request.isSpdy是false......所以spdy突然不被支持了?
这是我的HAproxy配置:global maxconn 4096
defaults
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http_proxy
mode http
bind *:80
redirect prefix https://awesome.com code 301
frontend https_proxy
mode tcp
bind *:443
default_backend webservers
backend webservers
balance source
server server1 127.0.0.1:10443 maxconn 4096
# server server2 127.0.0.1:10444 maxconn 4096
Run Code Online (Sandbox Code Playgroud)
谢谢!
我正在使用http://community.opscode.com/cookbooks/nginx在Vagrant上安装Nginx
我想让Nginx从我的配置文件开始/home/vagrant/nginx/nginx.conf,但它似乎坚持使用etc/nginx/nginx.conf
我的Vagrantfile的相关部分是:
chef.add_recipe "ohai"
chef.add_recipe "runit"
chef.add_recipe "nginx"
chef.json = {
:nginx => {
:install_method => "source",
:source => {
:version => "1.4.1",
:conf_path => "#{VAGRANT_HOME_DIRECTORY}/nginx/nginx.conf",
}
}
}
Run Code Online (Sandbox Code Playgroud)
这里发生了什么??
我似乎无法让node.js(v0.8.2)与spdy(v1.2.1)一起工作.这是我在coffeescript中的代码,因为它很酷:
spdy = require 'spdy'
fs = require 'fs'
DEFAULT_PORT = 8000
DEFAULT_SERVER_OPTIONS =
key: fs.readFileSync(__dirname + '/keys/privatekey.pem')
cert: fs.readFileSync(__dirname + '/keys/certificate.pem')
ca: fs.readFileSync(__dirname + '/keys/certrequest.csr')
spdy.createServer DEFAULT_SERVER_OPTIONS, (request, response) ->
console.log 'request made...'
response.writeHead 200
response.write 'goodbye cruel world'
response.end()
.listen DEFAULT_PORT
console.log 'Server running on ' + DEFAULT_PORT
Run Code Online (Sandbox Code Playgroud)
我看到"服务器运行在8000上",但是当我尝试连接到Chrome中的127.0.0.1:8000时,我什么都没得到,"请求发送..."永远不会消失.
非常感谢!