我正在尝试设置Apache以使用私钥和证书进行SSL使用.问题是Apache不知何故认为密钥和crt文件不匹配:
[Thu Aug 01 11:35:18 2013] [warn] RSA server certificate wildcard CommonName (CN) `*.-----.nl' does NOT match server name!?
[Thu Aug 01 11:35:18 2013] [debug] ssl_engine_init.c(846): Configuring RSA server private key
[Thu Aug 01 11:35:18 2013] [error] Unable to configure RSA server private key
[Thu Aug 01 11:35:18 2013] [error] SSL Library Error: 185073780 error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
Run Code Online (Sandbox Code Playgroud)
在此错误之后我检查了密钥和证书是否匹配使用:
$ openssl x509 -noout -modulus -in server.crt | openssl md5
$ openssl rsa -noout -modulus -in server.key | openssl md5 …Run Code Online (Sandbox Code Playgroud) 我在运行Linux的服务器上发生了一些奇怪的事情,而执行相同代码的Windows机器正常运行.
它发生在以下代码中:
public static final SimpleDateFormat sqlDateFormat = new SimpleDateFormat("Y-M-d");
Calendar cal = Calendar.getInstance();
String now = sqlDateFormat.format(cal.getTime());
System.out.println(now);
cal.add(Calendar.DAY_OF_MONTH, -4);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
String trsh = sqlDateFormat.format(cal.getTime());
System.out.println(trsh);
Run Code Online (Sandbox Code Playgroud)
Windows机器上的输出运行:
java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)
Output:
2014-01-02
2013-12-29
Run Code Online (Sandbox Code Playgroud)
以上与预期结果相符.
运行的Linux机器上的输出:
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b108)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b50, mixed mode)
Output:
2014-01-02
2014-12-29
Run Code Online (Sandbox Code Playgroud)
这很奇怪不是吗?有什么好的解决方法吗?
我正在为带有VAPID和有效负载加密的WebPush开发纯java实现(我已经为GCM和FCM实现了).然而,文档仍然是边缘的,代码样本仍然不重要.此刻,我正试图让它在Chrome中运行.尽管我使用VAPID获得了成功的订阅,当我发送Tickle或Payload推送消息时,我得到400 UnauthorizedRegistration.我的猜测是它与授权头或Crypto-Key头有关.这是我到目前为止发送的Tickle(没有有效载荷的推送通知):
URL: https://fcm.googleapis.com/fcm/send/xxxxx:xxxxxxxxxxx...
Action: POST/PUT (Both give same result)
With headers:
Authorization: Bearer URLBase64(JWT_HEAD).URLBase64(JWT_Payload).SIGN
Crypto-Key: p265ecdsa=X9.62(PublicKey)
Content-Type: "text/plain;charset=utf8"
Content-Length: 0
TTL: 120
JWT_HEAD="{\"typ\":\"JWT\",\"alg\":\"ES256\"}"
JWT_Payload={
aud: "https://fcm.googleapis.com",
exp: (System.currentTimeMillis() / 1000) + (60 * 60 * 12)),
sub: "mailto:webpush@mydomain.com"
}
SIGN = the "SHA256withECDSA" signature algorithm over: "URLBase64(JWT_HEAD).URLBase64(JWT_Payload)"
Run Code Online (Sandbox Code Playgroud)
我已经从JWT中的两个JSON中删除了空白,因为规范并不十分清楚空白使用,这似乎是最安全的事情.签名在再次将x9.62解码为ECPoint后验证,因此publicKey似乎是有效编码的.但是我一直得到回应:
<HTML><HEAD><TITLE>UnauthorizedRegistration</TITLE></HEAD><BODY BGCOLOR="#FFFFFF" TEXT="#000000"><H1>UnauthorizedRegistration</H1><H2>Error 400</H2></BODY></HTML>
Run Code Online (Sandbox Code Playgroud)
根据FCM文档,这仅在发生JSON错误时发生,但我觉得规范根本不包括WebPush.现在我已经尝试了Java加密提供程序中的构建,BC也产生了相同的结果.
一些代码片段用于澄清:
KeyGeneration:
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EC", "BC");
ECGenParameterSpec spec = new ECGenParameterSpec("secp256r1");
keyGen.initialize(spec, secureRandom);
KeyPair vapidPair = keyGen.generateKeyPair();
Run Code Online (Sandbox Code Playgroud)
ECPublicKey到x9.62:
public byte[] toUncompressedPoint(ECPublicKey publicKey){
final ECPoint publicPoint …Run Code Online (Sandbox Code Playgroud) 我此刻对此问题感到非常沮丧.我看不出我做错了什么.我有谷歌Chrome的这个问题,它给出了没有正确关闭的通知.我想摆脱这个.此外,我还有一些与全屏尺寸有关的旧版更换.在bash中,所有行都产生预期的结果; 但是,在脚本文件中,它会生成一个空的设置文件...
这些行在文件中:
cat ~/.config/google-chrome/Default/Preferences | perl -pe "s/\"work_area_bottom.*/\"work_area_bottom\": $(xrandr | grep \* | cut -d' ' -f4 | cut -d'x' -f2),/" > ~/.config/google-chrome/Default/Preferences
cat ~/.config/google-chrome/Default/Preferences | perl -pe "s/\"bottom.*/\"bottom\": $(xrandr | grep \* | cut -d' ' -f4 | cut -d'x' -f2),/" > ~/.config/google-chrome/Default/Preferences
cat ~/.config/google-chrome/Default/Preferences | perl -pe "s/\"work_area_right.*/\"work_area_right\": $(xrandr | grep \* | cut -d' ' -f4 | cut -d'x' -f1),/" > ~/.config/google-chrome/Default/Preferences
cat ~/.config/google-chrome/Default/Preferences | perl -pe "s/\"right.*/\"right\": $(xrandr | grep \* | cut -d' ' …Run Code Online (Sandbox Code Playgroud) 目前我正在更新我的 x.509 证书库以支持 ECC。大多数实现的构建器都采用 publicKey 并从密钥中导出算法等。在 RSA 中,这很简单,您可以检查密钥的算法并验证位长。但是对于 ECC,密钥基于曲线,曲线名称(当然)需要在证书中指定(作为 OID)。
我现在正在处理的问题是找到一种方法,从 java.security.interfaces.ECPublicKey 或 org.bouncycastle.jce.interfaces.ECPublicKey 到曲线名称。(两种实现完全不同......)
我能想到的一种方法是获取密钥的 ECPoint 并验证它是否在给定的曲线上。通过这种方式,我可以测试所有支持的曲线,但是在运行时感觉很麻烦,并且如果点重叠 2 条或更多曲线,则可能容易出错。
另一种方法是获取 ECCurve(bc 实现)或 EllipticCurve(jre 实现)并将曲线细节与支持的实现进行比较。这还涉及逐步遍历每条已知曲线。
有没有人知道仅使用 jre(8/9) 和 bc 根据曲线或公钥详细信息查找曲线名称的更好方法。您对第一个解决方案的感觉如何,获得误报的可能性有多大。