gpt4 book ai didi

iOS SecKeyRef(公钥)发送到服务器

转载 作者:技术小花猫 更新时间:2023-10-29 11:21:09 29 4
gpt4 key购买 nike

<分区>

现在我的公钥有问题,我使用 SecKeyGeneratePair 生成公钥和私钥。现在我必须将我的公钥发送到服务器。我使用下面的方法将 SecKeyRef 转换为 NSData,我总是得到相同的公钥。但是我把它转换成base64格式并发送到服务器。但它根本不起作用,服务器(Java)开始抛出错误。这是我的 iOS 代码:

- (NSData *)getPublicKeyBits {
OSStatus sanityCheck = noErr;
NSData * publicKeyBits = nil;

NSMutableDictionary * queryPublicKey = [[NSMutableDictionary alloc] init];

// Set the public key query dictionary.
[queryPublicKey setObject:(id)kSecClassKey forKey:(id)kSecClass];
[queryPublicKey setObject:publicTag forKey:(id)kSecAttrApplicationTag];
[queryPublicKey setObject:(id)kSecAttrKeyTypeRSA forKey:(id)kSecAttrKeyType];
[queryPublicKey setObject:[NSNumber numberWithBool:YES] forKey:(id)kSecReturnData];

// Get the key bits.
sanityCheck = SecItemCopyMatching((CFDictionaryRef)queryPublicKey, (CFTypeRef *)&publicKeyBits);

if (sanityCheck != noErr)
{
publicKeyBits = nil;
}

[queryPublicKey release];

return publicKeyBits;
}

谁能帮我把 SecKeyRef 转换成 NSString 或 NSData。

提前致谢!!!

-穆拉利克里希南

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com