区块链技术博客
www.b2bchain.cn

四年了没有媒人SDWebImage与Https自签名证书还是无法走到一起求职学习资料

本文介绍了四年了没有媒人SDWebImage与Https自签名证书还是无法走到一起求职学习资料,有助于帮助完成毕业设计以及求职,是一篇很好的资料。

对技术面试,学习经验等有一些体会,在此分享。

第二次遇到https的自签名证书下 SDWebImage下载图片无法显示的问题,记录一下

#import "UIImageView+JFHttps.h" #import <UIImageView+WebCache.h> #import <objc/runtime.h> @implementation UIImageView (JFHttps) + (void)load {    Class myClass = [self class];    // 获取SEL   SEL originSetImageSel = @selector(sd_setImageWithURL:placeholderImage:options:progress:completed:);   SEL newSetImageSel = @selector(sd_setHttpsImageWithURL:placeholderImage:options:progress:completed:);   // 生成Method   Method originMethod = class_getInstanceMethod(myClass, originSetImageSel);   Method newMethod = class_getInstanceMethod(myClass, newSetImageSel);   // 交换方法实现   method_exchangeImplementations(originMethod, newMethod); }  -(void)sd_setHttpsImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock {   if ([url.scheme isEqualToString:@"https"]) {      [self sd_setHttpsImageWithURL:url placeholderImage:placeholder options:SDWebImageAllowInvalidSSLCertificates progress:progressBlock completed:completedBlock];   }else {      [self sd_setHttpsImageWithURL:url placeholderImage:placeholder options:SDWebImageRetryFailed progress:progressBlock completed:completedBlock];     } } @end

把后端提供的证书在终端中使用命令转换一下导入项目中即可
openssl x509 -in certificate.crt -out certificate.cer -outform der
HooK SDWebImageDownloader下载图片的方法,运用AFNetworking的证书验证机制验证证书

第二次遇到https的自签名证书下 SDWebImage下载图片无法显示的问题,记录一下

#import "UIImageView+JFHttps.h" #import <UIImageView+WebCache.h> #import <objc/runtime.h> @implementation UIImageView (JFHttps) + (void)load {    Class myClass = [self class];    // 获取SEL   SEL originSetImageSel = @selector(sd_setImageWithURL:placeholderImage:options:progress:completed:);   SEL newSetImageSel = @selector(sd_setHttpsImageWithURL:placeholderImage:options:progress:completed:);   // 生成Method   Method originMethod = class_getInstanceMethod(myClass, originSetImageSel);   Method newMethod = class_getInstanceMethod(myClass, newSetImageSel);   // 交换方法实现   method_exchangeImplementations(originMethod, newMethod); }  -(void)sd_setHttpsImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock {   if ([url.scheme isEqualToString:@"https"]) {      [self sd_setHttpsImageWithURL:url placeholderImage:placeholder options:SDWebImageAllowInvalidSSLCertificates progress:progressBlock completed:completedBlock];   }else {      [self sd_setHttpsImageWithURL:url placeholderImage:placeholder options:SDWebImageRetryFailed progress:progressBlock completed:completedBlock];     } } @end

把后端提供的证书在终端中使用命令转换一下导入项目中即可
openssl x509 -in certificate.crt -out certificate.cer -outform der
HooK SDWebImageDownloader下载图片的方法,运用AFNetworking的证书验证机制验证证书

第二次遇到https的自签名证书下 SDWebImage下载图片无法显示的问题,记录一下

#import "UIImageView+JFHttps.h" #import <UIImageView+WebCache.h> #import <objc/runtime.h> @implementation UIImageView (JFHttps) + (void)load {    Class myClass = [self class];    // 获取SEL   SEL originSetImageSel = @selector(sd_setImageWithURL:placeholderImage:options:progress:completed:);   SEL newSetImageSel = @selector(sd_setHttpsImageWithURL:placeholderImage:options:progress:completed:);   // 生成Method   Method originMethod = class_getInstanceMethod(myClass, originSetImageSel);   Method newMethod = class_getInstanceMethod(myClass, newSetImageSel);   // 交换方法实现   method_exchangeImplementations(originMethod, newMethod); }  -(void)sd_setHttpsImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock {   if ([url.scheme isEqualToString:@"https"]) {      [self sd_setHttpsImageWithURL:url placeholderImage:placeholder options:SDWebImageAllowInvalidSSLCertificates progress:progressBlock completed:completedBlock];   }else {      [self sd_setHttpsImageWithURL:url placeholderImage:placeholder options:SDWebImageRetryFailed progress:progressBlock completed:completedBlock];     } } @end

把后端提供的证书在终端中使用命令转换一下导入项目中即可
openssl x509 -in certificate.crt -out certificate.cer -outform der
HooK SDWebImageDownloader下载图片的方法,运用AFNetworking的证书验证机制验证证书

部分转自互联网,侵权删除联系

赞(0) 打赏
部分文章转自网络,侵权联系删除b2bchain区块链学习技术社区 » 四年了没有媒人SDWebImage与Https自签名证书还是无法走到一起求职学习资料
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

b2b链

联系我们联系我们