简介:使用Google Cloud SQL提供的自签名证书时,PHP会出错.
详细信息:我正在尝试使用PHP的mysqli库连接到Google Cloud SQL的mysql实例.
$db = mysqli_init();
mysqli_options ($db, MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, true);
$db->ssl_set('client-key.pem', 'client-cert.pem', 'server-ca.pem', NULL, NULL);
$query = mysqli_real_connect ($db, $host, $user, $pass, $dbname, 3306, NULL, MYSQLI_CLIENT_SSL);
Run Code Online (Sandbox Code Playgroud)
据我所知,Google云允许自签名证书,我从那里下载了client-key.pem,client-cert.pem,server-ca.pem文件.
验证证书时,我从PHP收到以下错误:
mysqli_real_connect(): Peer certificate CN=`<project_name>' did not match expected CN=`<db_IP>'
Run Code Online (Sandbox Code Playgroud)
根据我到目前为止的研究,似乎我需要一种方法来禁用Verify_Peer检查,这显然是PHP不允许的.您能否验证这一点和/或提供一种方法来使用SSL中的Google Cloud SQL SSL?
谢谢.
我正在尝试使用JSON的ajax方法从服务器获取数据.
$.ajax({
dataType: "jsonp",
url: "https://secure.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json",
type: "GET",
data: "msg=aaa",
cache: true,
jsonp: "jsoncallback",
// jsonpCallback: "callbackmethod",
success: function(encryptedMsg){
console.log("Encryption success!");
},
error: function(req, errmsg, thrownError) {
console.log("Error: HTTP " + req.status + " " + errmsg);
}
});
Run Code Online (Sandbox Code Playgroud)
但是,错误控制台中显示以下错误:
Error: jQuery1720502636097747291_1339479763752 is not defined
Source File: https://secure.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=jQuery1720502636097747291_1339479763752&msg=aaa
Line: 1
Run Code Online (Sandbox Code Playgroud)
如果您打开源文件URL,您可以看到以下JSON,它似乎是正确的JSON.
jQuery1720502636097747291_1339479763752({
"title": "Recent Uploads tagged cat",
// ...
"items": [
{
"title": "Chaton",
// ...
},
// ...
]
})
Run Code Online (Sandbox Code Playgroud)
我还尝试用jsonpCallback指定方法名:"callbackmethod",但它没有用.我还使用了$ .getJson()方法和jquery-jsonp(http://code.google.com/p/jquery-jsonp/)但结果是一样的.
浏览器是Firefox并使用HTML4.这用于firefox插件.
你可以在这里阅读完整的代码:https://builder.addons.mozilla.org/addon/1048275/revision/749
我在common-content.js中的getEncryptedMessage函数中使用$ .ajax …
如何将数据写入stdout而不是写入文件?
我正在使用GPG并希望将加密文本打印到stdout,而不保存文件.
但是,使用gpg命令,加密文本以普通方式写入文件:
$> gpg --recipient someone@example.com --armor --output encrypted.txt --encrypt example.pdf
Run Code Online (Sandbox Code Playgroud)
(使用上面的命令,加密文件保存在encrypted.txt中)
我想做的是如下:
$> gpg --recipient someone@example.com --armor --output <STDOUT> --encrypt example.pdf
Run Code Online (Sandbox Code Playgroud)
和加密的消息显示在控制台中.
我不想保存硬盘以避免性能损失.
考虑在MongooseJS上运行的mongodb集合.
Person.where('uid').equals(19524121).select('name').exec(function(err, data){
// Here I can get the data correctly in an array.
console.log(JSON.stringify(data));
data[0].name = "try to save me now"; // Select the first item in the array
data[0].save(); // Object #<Promise> has no method 'save'.
}
Run Code Online (Sandbox Code Playgroud)
对象#<Promise>没有方法'save';
我对为什么会发生这种情况感到有些困惑,我已经研究了很多,似乎无法找到直接的答案.
我正在基于 Node.js 的 Web 应用程序中进行 CSV 导入。大多数给定的 CSV 文件都有数万条记录,并且需要几分钟的时间。
因此,在导入完成之前,我想向用户显示“当前正在导入...”消息。
我想要创建的内容类似于 Github 的分叉屏幕。按存储库右上角的分叉按钮后,它会显示消息“分叉/应该只需要几秒钟”。直到 fork 完成。此外,我想添加进度条来指示已处理记录的百分比。
目前我的实现是:
但实施后用户无法看到当前状态。甚至有时候socket会挂掉。
我正在考虑以下重新实现:
但是,我不知道:
服务器端如何实现?提前致谢 ;)
我正在尝试使用插件构建器开发firefox插件.
我想修改基于网络的邮件的邮件编辑器.(在下面的代码中,我正在尝试Yahoo! Japan的邮件服务.)
我想在用户按发送按钮时执行特定代码.
插件代码是:
main.js
var self = require("self");
var pageMod = require("page-mod");
pageMod.PageMod({
include: "*.mail.yahoo.co.jp",
contentScriptWhen: 'end',
contentScript: "document.getElementById('send_top').setAttribute('onclick', 'alert(\"blabla\")');"
});
Run Code Online (Sandbox Code Playgroud)
电子邮件编辑器页面中的按钮:
<input id="send_top" class="inputbutton" type="submit" title="Submit an email"
value="Submit" name="action_msg_send" accesskey="9">
Run Code Online (Sandbox Code Playgroud)
当用户"提交"按钮时,我想显示对话框.
我使用Ubuntu 14.10并从PostgreSQL官方apt存储库安装了PostgreSQL 9.2.(apt.postgresql.org)
当我切换用户postgres并尝试以下命令时,我可以成功登录.
$ psql -U postgres dbname -W
Password for user postgres: (Enter Password)
psql (9.2.9)
Type "help" for help.
dbname=#
Run Code Online (Sandbox Code Playgroud)
但是,当我指定主机值时,我无法使用以下错误登录.
$ psql -h localhost -U postgres notel -W
Password for user postgres:
psql: FATAL: password authentication failed for user "postgres"
FATAL: password authentication failed for user "postgres"
Run Code Online (Sandbox Code Playgroud)
我正在尝试从Sequelize.js连接,一个用于node.js的ORM,但我遇到了几乎相同的错误消息:
Possibly unhandled Error: error: password authentication failed for user "postgres"
Run Code Online (Sandbox Code Playgroud)
有谁知道我怎么能解决这个问题?
我的pg_hba.conf如下:
local all postgres peer
local all all peer
host all all 127.0.0.1/32 md5 …Run Code Online (Sandbox Code Playgroud)